MediaWiki  1.23.2
MemcachedBagOStuff Class Reference

Base class for memcached clients. More...

Inheritance diagram for MemcachedBagOStuff:
Collaboration diagram for MemcachedBagOStuff:

Public Member Functions

 add ( $key, $value, $exptime=0)
 
 cas ( $casToken, $key, $value, $exptime=0)
 
 decodeKey ( $key)
 Decode a key encoded with encodeKey(). More...
 
 delete ( $key, $time=0)
 
 encodeKey ( $key)
 Encode a key for use on the wire inside the memcached protocol. More...
 
 fixExpiry ( $expiry)
 TTLs higher than 30 days will be detected as absolute TTLs (UNIX timestamps), and will result in the cache entry being discarded immediately because the expiry is in the past. More...
 
 get ( $key, &$casToken=null)
 
 getClient ()
 Get the underlying client object. More...
 
 set ( $key, $value, $exptime=0)
 
- Public Member Functions inherited from BagOStuff
 clearLastError ()
 Clear the "last error" registry. More...
 
 debug ( $text)
 
 decr ( $key, $value=1)
 Decrease stored value of $key by $value while preserving its TTL. More...
 
 deleteObjectsExpiringBefore ( $date, $progressCallback=false)
 Delete all objects expiring before a certain date. More...
 
 getLastError ()
 Get the "last error" registered; clearLastError() should be called manually. More...
 
 getMulti (array $keys)
 Get an associative array containing the item for each of the keys that have items. More...
 
 incr ( $key, $value=1)
 Increase stored value of $key by $value while preserving its TTL. More...
 
 lock ( $key, $timeout=6)
 
 merge ( $key, closure $callback, $exptime=0, $attempts=10)
 Merge changes into the existing cache value (possibly creating a new one). More...
 
 replace ( $key, $value, $exptime=0)
 
 setDebug ( $bool)
 
 unlock ( $key)
 

Protected Member Functions

 applyDefaultParams ( $params)
 Fill in the defaults for any parameters missing from $params, using the backwards-compatible global variables. More...
 
 debugLog ( $text)
 Send a debug message to the log. More...
 
 encodeKeyCallback ( $m)
 
- Protected Member Functions inherited from BagOStuff
 convertExpiry ( $exptime)
 Convert an optionally relative time to an absolute time. More...
 
 convertToRelative ( $exptime)
 Convert an optionally absolute expiry time to a relative time. More...
 
 isInteger ( $value)
 Check if a value is an integer. More...
 
 mergeViaCas ( $key, closure $callback, $exptime=0, $attempts=10)
 
 mergeViaLock ( $key, closure $callback, $exptime=0, $attempts=10)
 
 setLastError ( $err)
 Set the "last error" registry. More...
 

Protected Attributes

 $client
 
- Protected Attributes inherited from BagOStuff
 $lastError = self::ERR_NONE
 

Additional Inherited Members

- Public Attributes inherited from BagOStuff
const ERR_NO_RESPONSE = 1
 
const ERR_NONE = 0
 Possible values for getLastError() More...
 
const ERR_UNEXPECTED = 3
 
const ERR_UNREACHABLE = 2
 

Detailed Description

Base class for memcached clients.

Definition at line 29 of file MemcachedBagOStuff.php.

Member Function Documentation

◆ add()

MemcachedBagOStuff::add (   $key,
  $value,
  $exptime = 0 
)
Parameters
$keystring
$valueint
int$exptime(default 0)
Returns
Mixed

Reimplemented from BagOStuff.

Reimplemented in MemcachedPeclBagOStuff.

Definition at line 105 of file MemcachedBagOStuff.php.

References $value, encodeKey(), and fixExpiry().

Referenced by MemcLockManager\acquireMutexes().

◆ applyDefaultParams()

MemcachedBagOStuff::applyDefaultParams (   $params)
protected

Fill in the defaults for any parameters missing from $params, using the backwards-compatible global variables.

Definition at line 36 of file MemcachedBagOStuff.php.

References $GLOBALS, and $params.

Referenced by MemcachedPhpBagOStuff\__construct(), and MemcachedPeclBagOStuff\__construct().

◆ cas()

MemcachedBagOStuff::cas (   $casToken,
  $key,
  $value,
  $exptime = 0 
)
Parameters
$keystring
$casTokenmixed
$value
$exptimeint
Returns
bool

Reimplemented from BagOStuff.

Reimplemented in MemcachedPeclBagOStuff.

Definition at line 85 of file MemcachedBagOStuff.php.

References $value, encodeKey(), and fixExpiry().

◆ debugLog()

◆ decodeKey()

MemcachedBagOStuff::decodeKey (   $key)

Decode a key encoded with encodeKey().

This is provided as a convenience function for debugging.

Parameters
$keystring
Returns
string

Definition at line 163 of file MemcachedBagOStuff.php.

◆ delete()

MemcachedBagOStuff::delete (   $key,
  $time = 0 
)
Parameters
$keystring
$timeint
Returns
bool

Reimplemented from BagOStuff.

Reimplemented in MemcachedPeclBagOStuff.

Definition at line 95 of file MemcachedBagOStuff.php.

References $time, and encodeKey().

Referenced by MemcLockManager\releaseMutexes().

◆ encodeKey()

MemcachedBagOStuff::encodeKey (   $key)

Encode a key for use on the wire inside the memcached protocol.

We encode spaces and line breaks to avoid protocol errors. We encode the other control characters for compatibility with libmemcached verify_key. We leave other punctuation alone, to maximise backwards compatibility.

Parameters
$keystring
Returns
string

Definition at line 128 of file MemcachedBagOStuff.php.

References array().

Referenced by add(), cas(), MemcachedPhpBagOStuff\decr(), delete(), get(), MemcachedPeclBagOStuff\get(), MemcachedPhpBagOStuff\incr(), MemcachedPhpBagOStuff\lock(), set(), and MemcachedPhpBagOStuff\unlock().

◆ encodeKeyCallback()

MemcachedBagOStuff::encodeKeyCallback (   $m)
protected
Parameters
$marray
Returns
string

Definition at line 137 of file MemcachedBagOStuff.php.

◆ fixExpiry()

MemcachedBagOStuff::fixExpiry (   $expiry)

TTLs higher than 30 days will be detected as absolute TTLs (UNIX timestamps), and will result in the cache entry being discarded immediately because the expiry is in the past.

Clamp expiries >30d at 30d, unless they're >=1e9 in which case they are likely to really be absolute (1e9 = 2011-09-09)

Definition at line 148 of file MemcachedBagOStuff.php.

Referenced by add(), cas(), and set().

◆ get()

MemcachedBagOStuff::get (   $key,
$casToken = null 
)
Parameters
$keystring
$casToken[optional]mixed
Returns
Mixed

Reimplemented from BagOStuff.

Reimplemented in MemcachedPeclBagOStuff.

Definition at line 63 of file MemcachedBagOStuff.php.

References encodeKey().

◆ getClient()

MemcachedBagOStuff::getClient ( )

Get the underlying client object.

This is provided for debugging purposes.

Definition at line 114 of file MemcachedBagOStuff.php.

References $client.

◆ set()

MemcachedBagOStuff::set (   $key,
  $value,
  $exptime = 0 
)
Parameters
$keystring
$value
$exptimeint
Returns
bool

Reimplemented from BagOStuff.

Reimplemented in MemcachedPeclBagOStuff.

Definition at line 73 of file MemcachedBagOStuff.php.

References $value, encodeKey(), and fixExpiry().

Member Data Documentation

◆ $client

MemcachedBagOStuff::$client
protected

Definition at line 30 of file MemcachedBagOStuff.php.

Referenced by getClient().


The documentation for this class was generated from the following file: