MediaWiki master
ObjectCache Class Reference
Collaboration diagram for ObjectCache:

Static Public Member Functions

static clear ()
 
static getAnythingId ()
 
static getInstance ( $id)
 Get a cached instance of the specified type of cache object.
 
static getLocalClusterInstance ()
 Get the main cluster-local cache object.
 
static getLocalServerInstance ( $fallback=CACHE_NONE)
 
static isDatabaseId ( $id)
 Determine whether a config ID would access the database.
 
static makeLocalServerCache ( $keyspace)
 Create a new BagOStuff instance for local-server caching.
 
static newAnything ()
 Factory function for CACHE_ANYTHING (referenced by configuration)
 
static newFromParams (array $params)
 

Static Public Attributes

static BagOStuff[] $instances = []
 
static string $localServerCacheClass
 

Detailed Description

See also
ObjectCacheFactory

Definition at line 30 of file ObjectCache.php.

Member Function Documentation

◆ clear()

static ObjectCache::clear ( )
static
Deprecated
since 1.42, Use ObjectCacheFactory::clear() instead.

Clear all the cached instances.

Definition at line 181 of file ObjectCache.php.

◆ getAnythingId()

static ObjectCache::getAnythingId ( )
static
Access: internal
Used by ObjectCacheFactory and ObjectCache.

Get the ID that will be used for CACHE_ANYTHING

Returns
string|int

Definition at line 94 of file ObjectCache.php.

References $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, CACHE_ACCEL, CACHE_ANYTHING, CACHE_DB, and CACHE_NONE.

◆ getInstance()

static ObjectCache::getInstance ( $id)
static

Get a cached instance of the specified type of cache object.

Deprecated
Use ObjectCacheFactory::getInstance instead.
Parameters
string | int$idA key in $wgObjectCaches.
Returns
BagOStuff

Definition at line 51 of file ObjectCache.php.

◆ getLocalClusterInstance()

static ObjectCache::getLocalClusterInstance ( )
static

Get the main cluster-local cache object.

Since
1.27
Returns
BagOStuff

Definition at line 143 of file ObjectCache.php.

Referenced by MediaWiki\Cache\FileCacheBase\getMissesRecent(), and MediaWiki\Cache\FileCacheBase\incrMissesRecent().

◆ getLocalServerInstance()

static ObjectCache::getLocalServerInstance ( $fallback = CACHE_NONE)
static
Deprecated
since 1.42, Use ObjectCacheFactory::getLocalServerInstance()
Parameters
int | string | array$fallbackFallback cache or parameter map with 'fallback'
Returns
BagOStuff
Exceptions
InvalidArgumentException
Since
1.27

Definition at line 132 of file ObjectCache.php.

References $fallback.

◆ isDatabaseId()

static ObjectCache::isDatabaseId ( $id)
static

Determine whether a config ID would access the database.

Parameters
string | int$idA key in $wgObjectCaches
Returns
bool

Definition at line 153 of file ObjectCache.php.

References $wgObjectCaches, and CACHE_ANYTHING.

◆ makeLocalServerCache()

static ObjectCache::makeLocalServerCache ( $keyspace)
static

Create a new BagOStuff instance for local-server caching.

Only use this if you explicitly require the creation of a fresh instance. Whenever possible, use or inject the object from MediaWikiServices::getLocalServerObjectCache() instead.

NOTE: This method is called very early via Setup.php by ExtensionRegistry, and thus must remain fairly standalone so as to not cause initialization of the MediaWikiServices singleton.

Access: internal
For use by ServiceWiring and ExtensionRegistry. There are use cases whereby we want to build up local server cache without service wiring available.
Since
1.35
Parameters
string$keyspace
Returns
BagOStuff

Definition at line 203 of file ObjectCache.php.

◆ newAnything()

static ObjectCache::newAnything ( )
static

Factory function for CACHE_ANYTHING (referenced by configuration)

CACHE_ANYTHING means that stuff has to be cached, not caching is not an option. If a caching method is configured for any of the main caches ($wgMainCacheType, $wgMessageCacheType, $wgParserCacheType), then CACHE_ANYTHING will effectively be an alias to the configured cache choice for that. If no cache choice is configured (by default $wgMainCacheType is CACHE_NONE), then CACHE_ANYTHING will forward to CACHE_DB.

Deprecated
since 1.42, Use ObjectCacheFactory::newInstance( ObjectCache::getAnythingId() );
Returns
BagOStuff

Definition at line 83 of file ObjectCache.php.

◆ newFromParams()

static ObjectCache::newFromParams ( array $params)
static
See also
ObjectCacheFactory::newFromParams()
Deprecated
since 1.42, Use ObjectCacheFactory::newFromParams instead.
Parameters
array$params
Returns
BagOStuff

Definition at line 63 of file ObjectCache.php.

References $params.

Member Data Documentation

◆ $instances

BagOStuff [] ObjectCache::$instances = []
static
Deprecated
Use ObjectCacheFactory instead. Map of (id => BagOStuff)

Definition at line 35 of file ObjectCache.php.

◆ $localServerCacheClass

string ObjectCache::$localServerCacheClass
static
Access: internal
for ObjectCacheTest

Definition at line 41 of file ObjectCache.php.


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