23use Wikimedia\ObjectFactory;
68 if ( empty(
$params[
'caches'] ) || !is_array(
$params[
'caches'] ) ) {
69 throw new InvalidArgumentException(
70 __METHOD__ .
': "caches" parameter must be an array of caches'
75 foreach (
$params[
'caches']
as $cacheInfo ) {
77 $this->caches[] = $cacheInfo;
79 if ( !isset( $cacheInfo[
'args'] ) ) {
84 $cacheInfo[
'args'] = [ $cacheInfo ];
86 $this->caches[] = ObjectFactory::getObjectFromSpec( $cacheInfo );
91 $this->asyncWrites = (
92 isset(
$params[
'replication'] ) &&
93 $params[
'replication'] ===
'async' &&
94 is_callable( $this->asyncHandler )
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 ) {
171 array_slice( $this->cacheIndexes, 1 ),
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 ) ) {
231 $val = $this->
get( $key, $flags );
232 if ( $val !==
false ) {
286 return $this->caches[0]->getLastError();
290 $this->caches[0]->clearLastError();
304 if ( array_diff( $indexes, [ 0 ] ) &&
$asyncWrites && $method !==
'merge' ) {
310 foreach ( $indexes
as $i ) {
311 $cache = $this->caches[$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 ) {
346 return $this->caches[0]->makeKey( ...func_get_args() );
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.' );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
unserialize( $serialized)
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.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
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))