23use Wikimedia\ObjectFactory;
69 throw new InvalidArgumentException(
70 __METHOD__ .
': "caches" parameter must be an array of caches'
75 foreach (
$params[
'caches'] as $cacheInfo ) {
79 if ( !
isset( $cacheInfo[
'args'] ) ) {
86 $this->caches[] = ObjectFactory::getObjectFromSpec( $cacheInfo );
91 $this->asyncWrites = (
93 $params[
'replication'] ===
'async' &&
97 $this->cacheIndexes =
array_keys( $this->caches );
101 foreach ( $this->caches as
$cache ) {
106 public function get( $key, $flags = 0 ) {
111 return $this->caches[0]->get( $key, $flags );
116 foreach ( $this->caches as $i =>
$cache ) {
133 [ $key,
$value, self::UPGRADE_TTL ]
139 public function set( $key,
$value, $exptime = 0, $flags = 0 ) {
148 public function delete( $key, $flags = 0 ) {
157 public function add( $key,
$value, $exptime = 0, $flags = 0 ) {
174 [ $key,
$value, $exptime, $flags ]
181 public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
190 public function changeTTL( $key, $exptime = 0, $flags = 0 ) {
199 public function lock( $key, $timeout = 6, $expiry = 6, $rclass =
'' ) {
201 return $this->caches[0]->lock( $key, $timeout, $expiry, $rclass );
206 return $this->caches[0]->unlock( $key );
218 foreach ( $this->caches as
$cache ) {
219 if (
$cache->deleteObjectsExpiringBefore( $date, $progressCallback ) ) {
230 foreach (
$keys as $key ) {
231 $val = $this->
get( $key, $flags );
232 if ( $val !==
false ) {
286 return $this->caches[0]->getLastError();
290 $this->caches[0]->clearLastError();
310 foreach ( $indexes as $i ) {
314 if ( !
$cache->$method( ...$args ) ) {
322 if ( !
$cache->$method( ...$args ) ) {
323 $logger->warning(
"Async $method op failed" );
342 return $this->caches[0]->makeKeyInternal( ...
func_get_args() );
345 public function makeKey( $class, $component =
null ) {
350 return $this->caches[0]->makeGlobalKey( ...
func_get_args() );
353 protected function doGet( $key, $flags = 0, &$casToken =
null ) {
354 throw new LogicException( __METHOD__ .
': proxy class does not need this method.' );
unserialize( $serialized)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Class representing a cache/ephemeral data store.
const READ_LATEST
Bitfield constants for get()/getMulti()
mergeFlagMaps(array $bags)
Merge the flag maps of one or more BagOStuff objects into a "lowest common denominator" map.
callable null $asyncHandler
A cache class that replicates all writes to multiple child caches.
setMulti(array $data, $exptime=0, $flags=0)
Batch insertion/replace.
usesAsyncWritesGivenFlags( $flags)
doWrite( $indexes, $asyncWrites, $method, array $args)
Apply a write method to the backing caches specified by $indexes (in order)
int[] $cacheIndexes
List of all backing cache indexes.
getLastError()
Get the "last error" registered; clearLastError() should be called manually.
__construct( $params)
$params include:
clearLastError()
Clear the "last error" registry.
incrWithInit( $key, $ttl, $value=1, $init=1)
Increase stored value of $key by $value while preserving its TTL.
incr( $key, $value=1)
Increase stored value of $key by $value while preserving its TTL.
add( $key, $value, $exptime=0, $flags=0)
Insert an item if it does not already exist.
changeTTL( $key, $exptime=0, $flags=0)
Change the expiration on a key if it exists.
merge( $key, callable $callback, $exptime=0, $attempts=10, $flags=0)
Merge changes into the existing cache value (possibly creating a new one)
makeGlobalKey( $class, $component=null)
Make a global cache key.
doGet( $key, $flags=0, &$casToken=null)
bool $asyncWrites
Use async secondary writes.
makeKeyInternal( $keyspace, $args)
Construct a cache key.
lock( $key, $timeout=6, $expiry=6, $rclass='')
Acquire an advisory lock on a key string.
makeKey( $class, $component=null)
Make a cache key, scoped to this instance's keyspace.
getMulti(array $keys, $flags=0)
Get an associative array containing the item for each of the keys that have items.
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.
deleteMulti(array $data, $flags=0)
Batch deletion.
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
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))