* 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 );
* @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 );
/**
* 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 ) {
*
* @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 ) {
*
* @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 ) {
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 ) {
}
usleep( $sleep ); // back off
$locked = $this->add( "{$key}:lock", $timeout );
- } while( !$locked );
+ } while ( !$locked );
return $locked;
}
/**
* 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.
/**
* 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 ) {
/**
* 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
*/