MediaWiki
REL1_24
|
interface is intended to be more or less compatible with the PHP memcached client. More...
Public Member Functions | |
add ($key, $value, $exptime=0) | |
cas ($casToken, $key, $value, $exptime=0) | |
Check and set an item. | |
clearLastError () | |
Clear the "last error" registry. | |
debug ($text) | |
decr ($key, $value=1) | |
Decrease stored value of $key by $value while preserving its TTL. | |
delete ($key, $time=0) | |
Delete an item. | |
deleteObjectsExpiringBefore ($date, $progressCallback=false) | |
Delete all objects expiring before a certain date. | |
get ($key, &$casToken=null) | |
Get an item with the given key. | |
getLastError () | |
Get the "last error" registered; clearLastError() should be called manually. | |
getMulti (array $keys) | |
Get an associative array containing the item for each of the keys that have items. | |
incr ($key, $value=1) | |
Increase stored value of $key by $value while preserving its TTL. | |
incrWithInit ($key, $ttl, $value=1, $init=1) | |
Increase stored value of $key by $value while preserving its TTL. | |
lock ($key, $timeout=6) | |
merge ($key, Closure $callback, $exptime=0, $attempts=10) | |
Merge changes into the existing cache value (possibly creating a new one). | |
set ($key, $value, $exptime=0) | |
Set an item. | |
setDebug ($bool) | |
setMulti (array $data, $exptime=0) | |
Batch insertion. | |
unlock ($key) | |
Public Attributes | |
const | ERR_NO_RESPONSE = 1 |
const | ERR_NONE = 0 |
Possible values for getLastError() | |
const | ERR_UNEXPECTED = 3 |
const | ERR_UNREACHABLE = 2 |
Protected Member Functions | |
convertExpiry ($exptime) | |
Convert an optionally relative time to an absolute time. | |
convertToRelative ($exptime) | |
Convert an optionally absolute expiry time to a relative time. | |
isInteger ($value) | |
Check if a value is an integer. | |
mergeViaCas ($key, Closure $callback, $exptime=0, $attempts=10) | |
mergeViaLock ($key, Closure $callback, $exptime=0, $attempts=10) | |
setLastError ($err) | |
Set the "last error" registry. | |
Protected Attributes | |
$lastError = self::ERR_NONE | |
Private Attributes | |
$debugMode = false |
interface is intended to be more or less compatible with the PHP memcached client.
backends for local hash array and SQL table included: $bag = new HashBagOStuff(); $bag = new SqlBagOStuff(); # connect to db first
Definition at line 43 of file BagOStuff.php.
BagOStuff::add | ( | $ | key, |
$ | value, | ||
$ | exptime = 0 |
||
) |
string | $key | |
mixed | $value | |
int | $exptime |
Reimplemented in RedisBagOStuff, MemcachedPeclBagOStuff, MultiWriteBagOStuff, and MemcachedBagOStuff.
Definition at line 273 of file BagOStuff.php.
Referenced by incrWithInit(), lock(), and mergeViaCas().
BagOStuff::cas | ( | $ | casToken, |
$ | key, | ||
$ | value, | ||
$ | exptime = 0 |
||
) | [abstract] |
Check and set an item.
mixed | $casToken | |
string | $key | |
mixed | $value | |
int | $exptime | Either an interval in seconds or a unix timestamp for expiry |
Reimplemented in SqlBagOStuff, MemcachedPeclBagOStuff, RedisBagOStuff, HashBagOStuff, MemcachedBagOStuff, MultiWriteBagOStuff, XCacheBagOStuff, WinCacheBagOStuff, APCBagOStuff, and EmptyBagOStuff.
Referenced by mergeViaCas().
Clear the "last error" registry.
Reimplemented in MultiWriteBagOStuff.
Definition at line 342 of file BagOStuff.php.
References ERR_NONE.
Referenced by lock().
BagOStuff::convertExpiry | ( | $ | exptime | ) | [protected] |
Convert an optionally relative time to an absolute time.
int | $exptime |
Definition at line 370 of file BagOStuff.php.
BagOStuff::convertToRelative | ( | $ | exptime | ) | [protected] |
Convert an optionally absolute expiry time to a relative time.
If an absolute time is specified which is in the past, use a short expiry time.
int | $exptime |
Definition at line 385 of file BagOStuff.php.
Referenced by RedisBagOStuff\add().
BagOStuff::debug | ( | $ | text | ) |
BagOStuff::decr | ( | $ | key, |
$ | value = 1 |
||
) |
Decrease stored value of $key by $value while preserving its TTL.
string | $key | |
int | $value |
Reimplemented in MemcachedPeclBagOStuff, MultiWriteBagOStuff, XCacheBagOStuff, APCBagOStuff, and MemcachedPhpBagOStuff.
Definition at line 308 of file BagOStuff.php.
BagOStuff::delete | ( | $ | key, |
$ | time = 0 |
||
) | [abstract] |
Delete an item.
string | $key | |
int | $time | Amount of time to delay the operation (mostly memcached-specific) |
Reimplemented in SqlBagOStuff, MemcachedPeclBagOStuff, RedisBagOStuff, HashBagOStuff, MultiWriteBagOStuff, MemcachedBagOStuff, XCacheBagOStuff, WinCacheBagOStuff, APCBagOStuff, and EmptyBagOStuff.
BagOStuff::deleteObjectsExpiringBefore | ( | $ | date, |
$ | progressCallback = false |
||
) |
Delete all objects expiring before a certain date.
string | $date | The reference date in MW format |
callable | bool | $progressCallback | Optional, a function which will be called regularly during long-running operations with the percentage progress as the first parameter. |
Reimplemented in SqlBagOStuff, and MultiWriteBagOStuff.
Definition at line 227 of file BagOStuff.php.
BagOStuff::get | ( | $ | key, |
&$ | casToken = null |
||
) | [abstract] |
Get an item with the given key.
Returns false if it does not exist.
string | $key | |
mixed | $casToken | [optional] |
Reimplemented in SqlBagOStuff, MemcachedPeclBagOStuff, RedisBagOStuff, MultiWriteBagOStuff, MemcachedBagOStuff, HashBagOStuff, WinCacheBagOStuff, XCacheBagOStuff, EmptyBagOStuff, and APCBagOStuff.
Get the "last error" registered; clearLastError() should be called manually.
Reimplemented in MultiWriteBagOStuff.
Definition at line 334 of file BagOStuff.php.
Referenced by lock().
BagOStuff::getMulti | ( | array $ | keys | ) |
Get an associative array containing the item for each of the keys that have items.
array | $keys | List of strings |
Reimplemented in MemcachedPeclBagOStuff, SqlBagOStuff, RedisBagOStuff, and MemcachedPhpBagOStuff.
Definition at line 239 of file BagOStuff.php.
BagOStuff::incr | ( | $ | key, |
$ | value = 1 |
||
) |
Increase stored value of $key by $value while preserving its TTL.
string | $key | Key to increase |
int | $value | Value to add to $key (Default 1) |
Reimplemented in SqlBagOStuff, RedisBagOStuff, MemcachedPeclBagOStuff, MultiWriteBagOStuff, XCacheBagOStuff, APCBagOStuff, and MemcachedPhpBagOStuff.
Definition at line 286 of file BagOStuff.php.
References $key, $n, $value, isInteger(), lock(), and unlock().
Referenced by decr(), and incrWithInit().
BagOStuff::incrWithInit | ( | $ | key, |
$ | ttl, | ||
$ | value = 1 , |
||
$ | init = 1 |
||
) |
BagOStuff::isInteger | ( | $ | value | ) | [protected] |
Check if a value is an integer.
mixed | $value |
Definition at line 403 of file BagOStuff.php.
References $value.
Referenced by APCBagOStuff\get(), XCacheBagOStuff\get(), incr(), APCBagOStuff\set(), and XCacheBagOStuff\set().
BagOStuff::lock | ( | $ | key, |
$ | timeout = 6 |
||
) |
string | $key | |
int | $timeout | [optional] |
Reimplemented in MultiWriteBagOStuff, and MemcachedPhpBagOStuff.
Definition at line 179 of file BagOStuff.php.
References $sleep, $timestamp, add(), clearLastError(), and getLastError().
Referenced by incr(), and mergeViaLock().
BagOStuff::merge | ( | $ | key, |
Closure $ | callback, | ||
$ | exptime = 0 , |
||
$ | attempts = 10 |
||
) |
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).
string | $key | |
Closure | $callback | Callback method to be executed |
int | $exptime | Either an interval in seconds or a unix timestamp for expiry |
int | $attempts | The amount of times to attempt a merge in case of failure |
Reimplemented in MultiWriteBagOStuff, XCacheBagOStuff, APCBagOStuff, and EmptyBagOStuff.
Definition at line 110 of file BagOStuff.php.
References $key, and mergeViaCas().
BagOStuff::mergeViaCas | ( | $ | key, |
Closure $ | callback, | ||
$ | exptime = 0 , |
||
$ | attempts = 10 |
||
) | [protected] |
string | $key | |
Closure | $callback | Callback method to be executed |
int | $exptime | Either an interval in seconds or a unix timestamp for expiry |
int | $attempts | The amount of times to attempt a merge in case of failure |
Definition at line 123 of file BagOStuff.php.
References $key, $success, $value, add(), and cas().
Referenced by merge().
BagOStuff::mergeViaLock | ( | $ | key, |
Closure $ | callback, | ||
$ | exptime = 0 , |
||
$ | attempts = 10 |
||
) | [protected] |
string | $key | |
Closure | $callback | Callback method to be executed |
int | $exptime | Either an interval in seconds or a unix timestamp for expiry |
int | $attempts | The amount of times to attempt a merge in case of failure |
Definition at line 152 of file BagOStuff.php.
References $key, $success, $value, lock(), and unlock().
Referenced by APCBagOStuff\merge(), and XCacheBagOStuff\merge().
BagOStuff::set | ( | $ | key, |
$ | value, | ||
$ | exptime = 0 |
||
) | [abstract] |
Set an item.
string | $key | |
mixed | $value | |
int | $exptime | Either an interval in seconds or a unix timestamp for expiry |
Reimplemented in SqlBagOStuff, MemcachedPeclBagOStuff, MultiWriteBagOStuff, RedisBagOStuff, HashBagOStuff, MemcachedBagOStuff, XCacheBagOStuff, WinCacheBagOStuff, APCBagOStuff, and EmptyBagOStuff.
BagOStuff::setDebug | ( | $ | bool | ) |
bool | $bool |
Reimplemented in MultiWriteBagOStuff, and MemcachedPhpBagOStuff.
Definition at line 57 of file BagOStuff.php.
BagOStuff::setLastError | ( | $ | err | ) | [protected] |
Set the "last error" registry.
int | $err | ERR_* constant |
Definition at line 351 of file BagOStuff.php.
Referenced by MemcachedPeclBagOStuff\checkResult().
BagOStuff::setMulti | ( | array $ | data, |
$ | exptime = 0 |
||
) |
Batch insertion.
array | $data | $key => $value assoc array |
int | $exptime | Either an interval in seconds or a unix timestamp for expiry |
Reimplemented in SqlBagOStuff, MemcachedPeclBagOStuff, and RedisBagOStuff.
Definition at line 257 of file BagOStuff.php.
BagOStuff::unlock | ( | $ | key | ) |
string | $key |
Reimplemented in MultiWriteBagOStuff, and MemcachedPhpBagOStuff.
Definition at line 214 of file BagOStuff.php.
Referenced by incr(), and mergeViaLock().
BagOStuff::$debugMode = false [private] |
Definition at line 44 of file BagOStuff.php.
BagOStuff::$lastError = self::ERR_NONE [protected] |
Definition at line 46 of file BagOStuff.php.
const BagOStuff::ERR_NO_RESPONSE = 1 |
Definition at line 50 of file BagOStuff.php.
const BagOStuff::ERR_NONE = 0 |
Possible values for getLastError()
Definition at line 49 of file BagOStuff.php.
Referenced by clearLastError(), and MultiWriteBagOStuff\getLastError().
const BagOStuff::ERR_UNEXPECTED = 3 |
Definition at line 52 of file BagOStuff.php.
Referenced by MemcachedPeclBagOStuff\checkResult().
const BagOStuff::ERR_UNREACHABLE = 2 |
Definition at line 51 of file BagOStuff.php.