objectcache: Use faster getArrayCopy() in WAN cache methods
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 8 Jun 2017 14:49:28 +0000 (07:49 -0700)
committerKrinkle <krinklemail@gmail.com>
Sat, 10 Jun 2017 15:26:37 +0000 (15:26 +0000)
Change-Id: I5f0543a59bdc59656c54fab4d7c4ae33fd233f9a

includes/libs/objectcache/WANObjectCache.php

index 423d43e..58e4e09 100644 (file)
@@ -1109,7 +1109,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
        final public function getMultiWithSetCallback(
                ArrayIterator $keyedIds, $ttl, callable $callback, array $opts = []
        ) {
-               $valueKeys = array_keys( iterator_to_array( $keyedIds, true ) );
+               $valueKeys = array_keys( $keyedIds->getArrayCopy() );
                $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] : [];
 
                // Load required keys into process cache in one go
@@ -1195,7 +1195,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
        final public function getMultiWithUnionSetCallback(
                ArrayIterator $keyedIds, $ttl, callable $callback, array $opts = []
        ) {
-               $idsByValueKey = iterator_to_array( $keyedIds, true );
+               $idsByValueKey = $keyedIds->getArrayCopy();
                $valueKeys = array_keys( $idsByValueKey );
                $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] : [];
                unset( $opts['lockTSE'] ); // incompatible