65 if ( empty(
$params[
'caches'] ) || !is_array(
$params[
'caches'] ) ) {
66 throw new InvalidArgumentException(
67 __METHOD__ .
': "caches" parameter must be an array of caches'
72 foreach (
$params[
'caches'] as $cacheInfo ) {
74 $this->caches[] = $cacheInfo;
76 if ( !isset( $cacheInfo[
'args'] ) ) {
81 $cacheInfo[
'args'] = [ $cacheInfo ];
83 $this->caches[] = ObjectFactory::getObjectFromSpec( $cacheInfo );
88 $this->asyncWrites = (
89 isset(
$params[
'replication'] ) &&
90 $params[
'replication'] ===
'async' &&
91 is_callable( $this->asyncHandler )
96 foreach ( $this->caches as
$cache ) {
102 if ( (
$flags & self::READ_LATEST ) == self::READ_LATEST ) {
106 return $this->caches[0]->get( $key,
$flags );
111 foreach ( $this->caches as
$cache ) {
121 && (
$flags & self::READ_VERIFIED ) == self::READ_VERIFIED
123 $this->
doWrite( $misses, $this->asyncWrites,
'set', $key,
$value, self::UPGRADE_TTL );
137 public function delete( $key ) {
138 return $this->
doWrite( self::ALL, $this->asyncWrites,
'delete', $key );
142 return $this->
doWrite( self::ALL, $this->asyncWrites,
'add', $key,
$value, $exptime );
146 return $this->
doWrite( self::ALL, $this->asyncWrites,
'incr', $key,
$value );
150 return $this->
doWrite( self::ALL, $this->asyncWrites,
'decr', $key,
$value );
153 public function lock( $key, $timeout = 6, $expiry = 6, $rclass =
'' ) {
155 return $this->caches[0]->lock( $key, $timeout, $expiry, $rclass );
160 return $this->caches[0]->unlock( $key );
164 return $this->caches[0]->getLastError();
168 $this->caches[0]->clearLastError();
182 $args = array_slice( func_get_args(), 3 );
190 foreach ( $this->caches as $i =>
$cache ) {
191 if ( $i >= $count ) {
197 if ( !call_user_func_array( [
$cache, $method ],
$args ) ) {
206 if ( !call_user_func_array( [
$cache, $method ],
$args ) ) {
207 $logger->warning(
"Async $method op failed" );
227 foreach ( $this->caches as
$cache ) {
228 if (
$cache->deleteObjectsExpiringBefore( $date, $progressCallback ) ) {
237 return call_user_func_array( [ $this->caches[0], __FUNCTION__ ], func_get_args() );
241 return call_user_func_array( [ $this->caches[0], __FUNCTION__ ], func_get_args() );
unserialize( $serialized)
interface is intended to be more or less compatible with the PHP memcached client.
const WRITE_SYNC
Bitfield constants for set()/merge()
mergeFlagMaps(array $bags)
Merge the flag maps of one or more BagOStuff objects into a "lowest common denominator" map.
A cache class that replicates all writes to multiple child caches.
doWrite( $count, $asyncWrites, $method)
Apply a write method to the first $count backing caches.
makeGlobalKey()
Make a global cache key.
add( $key, $value, $exptime=0)
getLastError()
Get the "last error" registered; clearLastError() should be called manually.
__construct( $params)
$params include:
clearLastError()
Clear the "last error" registry.
incr( $key, $value=1)
Increase stored value of $key by $value while preserving its TTL.
bool $asyncWrites
Use async secondary writes.
lock( $key, $timeout=6, $expiry=6, $rclass='')
Acquire an advisory lock on a key string.
const ALL
Idiom for "write to all backends".
deleteObjectsExpiringBefore( $date, $progressCallback=false)
Delete objects expiring before a certain date.
decr( $key, $value=1)
Decrease stored value of $key by $value while preserving its TTL.
unlock( $key)
Release an advisory lock on a key string.
makeKey()
Make a cache key, scoped to this instance's keyspace.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
processing should stop and the error should be shown to the user * false