MediaWiki  1.23.2
MemcachedPeclBagOStuff Class Reference

A wrapper class for the PECL memcached client. More...

Inheritance diagram for MemcachedPeclBagOStuff:
Collaboration diagram for MemcachedPeclBagOStuff:

Public Member Functions

 __construct ( $params)
 Constructor. More...
 
 add ( $key, $value, $exptime=0)
 
 cas ( $casToken, $key, $value, $exptime=0)
 
 decr ( $key, $value=1)
 
 delete ( $key, $time=0)
 
 get ( $key, &$casToken=null)
 
 getMulti (array $keys)
 
 incr ( $key, $value=1)
 
 set ( $key, $value, $exptime=0)
 
- Public Member Functions inherited from MemcachedBagOStuff
 decodeKey ( $key)
 Decode a key encoded with encodeKey(). More...
 
 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...
 
 getClient ()
 Get the underlying client object. More...
 
- Public Member Functions inherited from BagOStuff
 clearLastError ()
 Clear the "last error" registry. More...
 
 debug ( $text)
 
 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...
 
 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

 checkResult ( $key, $result)
 Check the return value from a client method call and take any necessary action. More...
 
- Protected Member Functions inherited from MemcachedBagOStuff
 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...
 

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
 
- Protected Attributes inherited from MemcachedBagOStuff
 $client
 
- Protected Attributes inherited from BagOStuff
 $lastError = self::ERR_NONE
 

Detailed Description

A wrapper class for the PECL memcached client.

Definition at line 29 of file MemcachedPeclBagOStuff.php.

Constructor & Destructor Documentation

◆ __construct()

MemcachedPeclBagOStuff::__construct (   $params)

Constructor.

Available parameters are:

  • servers: The list of IP:port combinations holding the memcached servers.
  • persistent: Whether to use a persistent connection
  • compress_threshold: The minimum size an object must be before it is compressed
  • timeout: The read timeout in microseconds
  • connect_timeout: The connect timeout in seconds
  • retry_timeout: Time in seconds to wait before retrying a failed connect attempt
  • server_failure_limit: Limit for server connect failures before it is removed
  • serializer: May be either "php" or "igbinary". Igbinary produces more compact values, but serialization is much slower unless the php.ini option igbinary.compact_strings is off.

Definition at line 46 of file MemcachedPeclBagOStuff.php.

References $params, MemcachedBagOStuff\applyDefaultParams(), array(), as, IP\splitHostAndPort(), and wfDebug().

Member Function Documentation

◆ add()

MemcachedPeclBagOStuff::add (   $key,
  $value,
  $exptime = 0 
)
Parameters
$keystring
$valueint
$exptimeint
Returns
Mixed

Reimplemented from MemcachedBagOStuff.

Definition at line 174 of file MemcachedPeclBagOStuff.php.

References $value, add, checkResult(), and MemcachedBagOStuff\debugLog().

◆ cas()

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

Reimplemented from MemcachedBagOStuff.

Definition at line 147 of file MemcachedPeclBagOStuff.php.

References $value, checkResult(), and MemcachedBagOStuff\debugLog().

◆ checkResult()

MemcachedPeclBagOStuff::checkResult (   $key,
  $result 
)
protected

Check the return value from a client method call and take any necessary action.

Returns the value that the wrapper function should return. At present, the return value is always the same as the return value from the client, but some day we might find a case where it should be different.

Parameters
string$keyThe key used by the caller, or false if there wasn't one.
$resultMixed The return value
Returns
Mixed

Definition at line 212 of file MemcachedPeclBagOStuff.php.

References MemcachedBagOStuff\debugLog(), BagOStuff\ERR_UNEXPECTED, BagOStuff\setLastError(), and wfDebugLog().

Referenced by add(), cas(), decr(), delete(), get(), getMulti(), incr(), and set().

◆ decr()

MemcachedPeclBagOStuff::decr (   $key,
  $value = 1 
)
Parameters
$keystring
$valueint
Returns
Mixed

Reimplemented from BagOStuff.

Definition at line 195 of file MemcachedPeclBagOStuff.php.

References $value, checkResult(), and MemcachedBagOStuff\debugLog().

◆ delete()

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

Reimplemented from MemcachedBagOStuff.

Definition at line 157 of file MemcachedPeclBagOStuff.php.

References $time, checkResult(), and MemcachedBagOStuff\debugLog().

◆ get()

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

Reimplemented from MemcachedBagOStuff.

Definition at line 120 of file MemcachedPeclBagOStuff.php.

References checkResult(), MemcachedBagOStuff\debugLog(), MemcachedBagOStuff\encodeKey(), wfProfileIn(), and wfProfileOut().

◆ getMulti()

MemcachedPeclBagOStuff::getMulti ( array  $keys)
Parameters
$keysArray
Returns
Array

Reimplemented from BagOStuff.

Definition at line 243 of file MemcachedPeclBagOStuff.php.

References $keys, array(), checkResult(), MemcachedBagOStuff\debugLog(), wfProfileIn(), and wfProfileOut().

◆ incr()

MemcachedPeclBagOStuff::incr (   $key,
  $value = 1 
)
Parameters
$keystring
$valueint
Returns
Mixed

Reimplemented from BagOStuff.

Definition at line 184 of file MemcachedPeclBagOStuff.php.

References $value, checkResult(), and MemcachedBagOStuff\debugLog().

◆ set()

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

Reimplemented from MemcachedBagOStuff.

Definition at line 135 of file MemcachedPeclBagOStuff.php.

References $value, checkResult(), MemcachedBagOStuff\debugLog(), and set.


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