65 if ( empty(
$params[
'caches'] ) || !is_array(
$params[
'caches'] ) ) {
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 ];
88 $this->asyncWrites = (
89 isset(
$params[
'replication'] ) &&
90 $params[
'replication'] ===
'async' &&
91 is_callable( $this->asyncHandler )
96 foreach ( $this->caches
as $cache ) {
97 $cache->setDebug(
$debug );
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 );
184 foreach ( $this->caches
as $i =>
$cache ) {
191 if ( !call_user_func_array( [
$cache, $method ],
$args ) ) {
200 if ( !call_user_func_array( [
$cache, $method ],
$args ) ) {
201 $logger->warning(
"Async $method op failed" );
221 foreach ( $this->caches
as $cache ) {
222 if ( $cache->deleteObjectsExpiringBefore( $date, $progressCallback ) ) {
static getObjectFromSpec($spec)
Instantiate an object based on a specification array.
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
doWrite($count, $asyncWrites, $method)
Apply a write method to the first $count backing caches.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
add($key, $value, $exptime=0)
it s the revision text itself In either if gzip is the revision text is gzipped $flags
const ALL
Idiom for "write to all backends".
__construct($params)
$params include:
A cache class that replicates all writes to multiple child caches.
bool $asyncWrites
Use async secondary writes.
lock($key, $timeout=6, $expiry=6, $rclass= '')
mergeFlagMaps(array $bags)
Merge the flag maps of one or more BagOStuff objects into a "lowest common denominator" map...
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
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
deleteObjectsExpiringBefore($date, $progressCallback=false)
Delete objects expiring before a certain date.
set($key, $value, $exptime=0, $flags=0)