From: Aaron Schulz Date: Wed, 30 Sep 2015 04:28:30 +0000 (-0700) Subject: Cleaned up WANObjectCache toy example code blocks X-Git-Tag: 1.31.0-rc.0~9641^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=3f3d5a10b9dab98c4723c1703abb1be0b097cb71;p=lhc%2Fweb%2Fwiklou.git Cleaned up WANObjectCache toy example code blocks The list order logic was backwards Change-Id: Id26e13b69d9e1e6ef132792bdcc693836757cbd8 --- diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index e5bc66502a..7e8db0cc00 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -593,12 +593,12 @@ class WANObjectCache { * function( $oldValue, &$ttl, array &$setOpts ) { * $dbr = wfGetDB( DB_SLAVE ); * // Start off with the last cached list - * $list = $oldValue ? $oldValue : array(); - * $last = end( $list ); - * // Fetch any rows newer than $last from the DB (in order) + * $list = $oldValue ?: array(); + * // Fetch the last 100 relevant rows in descending order; + * // only fetch rows newer than $list[0] to reduce scanning * $rows = iterator_to_array( $dbr->select( ... ) ); * // Merge them and get the new "last 100" rows - * $list = array_slice( array_merge( $list, $new ), -100 ); + * $list = array_slice( array_merge( $new, $list ), 0, 100 ); * * // Set age of the transaction snapshot the data came from * $setOpts = array( 'since' => $dbr->trxTimestamp() ); @@ -606,12 +606,12 @@ class WANObjectCache { * return $list; * }, * // Time-to-live (seconds) - * 10 + * 10, * // No "check" keys * array(), * // Try to only let one datacenter thread manage cache updates at a time * array( 'lockTSE' => 30 ) - * ) ); + * ); * @endcode * * @see WANObjectCache::get()