X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fobjectcache%2FBagOStuff.php;h=58ddd6a001e33964853e0290254e936e36abb3fd;hb=12f5ab9a3f40128b26a72a742602740c633b6fcc;hp=03b0d5b920d2162e83571157dc99b1a711b059d9;hpb=2a6ed8846065696a6cddd9e3a6dd4e1401e750a6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/objectcache/BagOStuff.php b/includes/objectcache/BagOStuff.php index 03b0d5b920..58ddd6a001 100644 --- a/includes/objectcache/BagOStuff.php +++ b/includes/objectcache/BagOStuff.php @@ -65,7 +65,7 @@ abstract class BagOStuff { * Set an item. * @param $key string * @param $value mixed - * @param $exptime int Either an interval in seconds or a unix timestamp for expiry + * @param int $exptime Either an interval in seconds or a unix timestamp for expiry * @return bool success */ abstract public function set( $key, $value, $exptime = 0 ); @@ -75,7 +75,7 @@ abstract class BagOStuff { * @param $casToken mixed * @param $key string * @param $value mixed - * @param $exptime int Either an interval in seconds or a unix timestamp for expiry + * @param int $exptime Either an interval in seconds or a unix timestamp for expiry * @return bool success */ abstract public function cas( $casToken, $key, $value, $exptime = 0 ); @@ -83,18 +83,20 @@ abstract class BagOStuff { /** * Delete an item. * @param $key string - * @param $time int Amount of time to delay the operation (mostly memcached-specific) + * @param int $time Amount of time to delay the operation (mostly memcached-specific) * @return bool True if the item was deleted or not found, false on failure */ abstract public function delete( $key, $time = 0 ); /** - * Merge changes into the existing cache value (possibly creating a new one) + * Merge changes into the existing cache value (possibly creating a new one). + * The callback function returns the new value given the current value (possibly false), + * and takes the arguments: (this BagOStuff object, cache key, current value). * * @param $key string * @param $callback closure Callback method to be executed - * @param $exptime int Either an interval in seconds or a unix timestamp for expiry - * @param $attempts int The amount of times to attempt a merge in case of failure + * @param int $exptime Either an interval in seconds or a unix timestamp for expiry + * @param int $attempts The amount of times to attempt a merge in case of failure * @return bool success */ public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) { @@ -106,8 +108,8 @@ abstract class BagOStuff { * * @param $key string * @param $callback closure Callback method to be executed - * @param $exptime int Either an interval in seconds or a unix timestamp for expiry - * @param $attempts int The amount of times to attempt a merge in case of failure + * @param int $exptime Either an interval in seconds or a unix timestamp for expiry + * @param int $attempts The amount of times to attempt a merge in case of failure * @return bool success */ protected function mergeViaCas( $key, closure $callback, $exptime = 0, $attempts = 10 ) { @@ -135,8 +137,8 @@ abstract class BagOStuff { * * @param $key string * @param $callback closure Callback method to be executed - * @param $exptime int Either an interval in seconds or a unix timestamp for expiry - * @param $attempts int The amount of times to attempt a merge in case of failure + * @param int $exptime Either an interval in seconds or a unix timestamp for expiry + * @param int $attempts The amount of times to attempt a merge in case of failure * @return bool success */ protected function mergeViaLock( $key, closure $callback, $exptime = 0, $attempts = 10 ) { @@ -172,10 +174,10 @@ abstract class BagOStuff { return true; } - $uRTT = ceil( 1e6 * ( microtime( true ) - $timestamp ) ); // estimate RTT (us) - $sleep = 2*$uRTT; // rough time to do get()+set() + $uRTT = ceil( 1e6 * ( microtime( true ) - $timestamp ) ); // estimate RTT (us) + $sleep = 2 * $uRTT; // rough time to do get()+set() - $locked = false; // lock acquired + $locked = false; // lock acquired $attempts = 0; // failed attempts do { if ( ++$attempts >= 3 && $sleep <= 1e6 ) { @@ -185,7 +187,7 @@ abstract class BagOStuff { } usleep( $sleep ); // back off $locked = $this->add( "{$key}:lock", $timeout ); - } while( !$locked ); + } while ( !$locked ); return $locked; } @@ -200,7 +202,7 @@ abstract class BagOStuff { /** * Delete all objects expiring before a certain date. - * @param $date string The reference date in MW format + * @param string $date The reference date in MW format * @param $progressCallback callback|bool Optional, a function which will be called * regularly during long-running operations with the percentage progress * as the first parameter. @@ -216,7 +218,7 @@ abstract class BagOStuff { /** * Get an associative array containing the item for each of the keys that have items. - * @param $keys Array List of strings + * @param array $keys List of strings * @return Array */ public function getMulti( array $keys ) { @@ -258,7 +260,7 @@ abstract class BagOStuff { /** * Increase stored value of $key by $value while preserving its TTL - * @param $key String: Key to increase + * @param string $key Key to increase * @param $value Integer: Value to add to $key (Default 1) * @return integer|bool New value or false on failure */