MediaWiki  1.23.3
MultiWriteBagOStuff Class Reference

A cache class that replicates all writes to multiple child caches. More...

Inheritance diagram for MultiWriteBagOStuff:
Collaboration diagram for MultiWriteBagOStuff:

Public Member Functions

 __construct ( $params)
 Constructor. More...
 
 add ( $key, $value, $exptime=0)
 
 cas ( $casToken, $key, $value, $exptime=0)
 
 clearLastError ()
 Clear the "last error" registry. More...
 
 decr ( $key, $value=1)
 
 delete ( $key, $time=0)
 
 deleteObjectsExpiringBefore ( $date, $progressCallback=false)
 Delete objects expiring before a certain date. More...
 
 get ( $key, &$casToken=null)
 
 getLastError ()
 Get the "last error" registered; clearLastError() should be called manually. More...
 
 incr ( $key, $value=1)
 
 lock ( $key, $timeout=0)
 
 merge ( $key, closure $callback, $exptime=0, $attempts=10)
 
 replace ( $key, $value, $exptime=0)
 
 set ( $key, $value, $exptime=0)
 
 setDebug ( $debug)
 
 unlock ( $key)
 
- Public Member Functions inherited from BagOStuff
 debug ( $text)
 
 getMulti (array $keys)
 Get an associative array containing the item for each of the keys that have items. More...
 

Public Attributes

 $caches
 
- 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 Member Functions

 doWrite ( $method)
 
- 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

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

Detailed Description

A cache class that replicates all writes to multiple child caches.

Reads are implemented by reading from the caches in the order they are given in the configuration until a cache gives a positive result.

Definition at line 31 of file MultiWriteBagOStuff.php.

Constructor & Destructor Documentation

◆ __construct()

MultiWriteBagOStuff::__construct (   $params)

Constructor.

Parameters are:

  • caches: This should have a numbered array of cache parameter structures, in the style required by $wgObjectCaches. See the documentation of $wgObjectCaches for more detail.
Parameters
$paramsarray
Exceptions
MWException

Definition at line 44 of file MultiWriteBagOStuff.php.

References $params, array(), as, and ObjectCache\newFromParams().

Member Function Documentation

◆ add()

MultiWriteBagOStuff::add (   $key,
  $value,
  $exptime = 0 
)
Parameters
$keystring
$valuemixed
$exptimeint
Returns
bool

Reimplemented from BagOStuff.

Definition at line 113 of file MultiWriteBagOStuff.php.

References $value, and doWrite().

◆ cas()

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

Reimplemented from BagOStuff.

Definition at line 84 of file MultiWriteBagOStuff.php.

◆ clearLastError()

MultiWriteBagOStuff::clearLastError ( )

Clear the "last error" registry.

Since
1.23

Reimplemented from BagOStuff.

Definition at line 186 of file MultiWriteBagOStuff.php.

◆ decr()

MultiWriteBagOStuff::decr (   $key,
  $value = 1 
)
Parameters
$keystring
$valueint
Returns
bool

Reimplemented from BagOStuff.

Definition at line 141 of file MultiWriteBagOStuff.php.

References $value, and doWrite().

◆ delete()

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

Reimplemented from BagOStuff.

Definition at line 103 of file MultiWriteBagOStuff.php.

References $time, and doWrite().

◆ deleteObjectsExpiringBefore()

MultiWriteBagOStuff::deleteObjectsExpiringBefore (   $date,
  $progressCallback = false 
)

Delete objects expiring before a certain date.

Succeed if any of the child caches succeed.

Parameters
$datestring
$progressCallbackbool|callback
Returns
bool

Reimplemented from BagOStuff.

Definition at line 217 of file MultiWriteBagOStuff.php.

References $cache, $ret, and as.

◆ doWrite()

MultiWriteBagOStuff::doWrite (   $method)
protected
Parameters
$methodstring
Returns
bool

Definition at line 196 of file MultiWriteBagOStuff.php.

References $args, $cache, $ret, array(), and as.

Referenced by add(), decr(), delete(), incr(), merge(), replace(), set(), and setDebug().

◆ get()

MultiWriteBagOStuff::get (   $key,
$casToken = null 
)
Parameters
$keystring
$casToken[optional]mixed
Returns
bool|mixed

Reimplemented from BagOStuff.

Definition at line 67 of file MultiWriteBagOStuff.php.

References $cache, $value, and as.

◆ getLastError()

MultiWriteBagOStuff::getLastError ( )

Get the "last error" registered; clearLastError() should be called manually.

Returns
integer ERR_* constant for the "last error" registry
Since
1.23

Reimplemented from BagOStuff.

Definition at line 182 of file MultiWriteBagOStuff.php.

References BagOStuff\ERR_NONE.

◆ incr()

MultiWriteBagOStuff::incr (   $key,
  $value = 1 
)
Parameters
$keystring
$valueint
Returns
bool|null

Reimplemented from BagOStuff.

Definition at line 132 of file MultiWriteBagOStuff.php.

References $value, and doWrite().

◆ lock()

MultiWriteBagOStuff::lock (   $key,
  $timeout = 0 
)
Parameters
$keystring
$timeoutint
Returns
bool

Reimplemented from BagOStuff.

Definition at line 150 of file MultiWriteBagOStuff.php.

◆ merge()

MultiWriteBagOStuff::merge (   $key,
closure  $callback,
  $exptime = 0,
  $attempts = 10 
)
Parameters
$keystring
$callbackclosure Callback method to be executed
int$exptimeEither an interval in seconds or a unix timestamp for expiry
int$attemptsThe amount of times to attempt a merge in case of failure
Returns
bool success

Reimplemented from BagOStuff.

Definition at line 178 of file MultiWriteBagOStuff.php.

References doWrite().

◆ replace()

MultiWriteBagOStuff::replace (   $key,
  $value,
  $exptime = 0 
)
Parameters
$keystring
$valuemixed
$exptimeint
Returns
bool

Reimplemented from BagOStuff.

Definition at line 123 of file MultiWriteBagOStuff.php.

References $value, and doWrite().

◆ set()

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

Reimplemented from BagOStuff.

Definition at line 94 of file MultiWriteBagOStuff.php.

References $value, and doWrite().

◆ setDebug()

MultiWriteBagOStuff::setDebug (   $debug)
Parameters
$debugbool

Reimplemented from BagOStuff.

Definition at line 58 of file MultiWriteBagOStuff.php.

References $debug, and doWrite().

◆ unlock()

MultiWriteBagOStuff::unlock (   $key)
Parameters
$keystring
Returns
bool

Reimplemented from BagOStuff.

Definition at line 163 of file MultiWriteBagOStuff.php.

Member Data Documentation

◆ $caches

MultiWriteBagOStuff::$caches

Definition at line 32 of file MultiWriteBagOStuff.php.


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