MediaWiki
master
|
Functions to get cache objects. More...
Static Public Member Functions | |
static | clear () |
Clear all the cached instances. More... | |
static | getDefaultKeyspace () |
Get the default keyspace for this wiki. More... | |
static | getInstance ($id) |
Get a cached instance of the specified type of cache object. More... | |
static | getLocalClusterInstance () |
Get the main cluster-local cache object. More... | |
static | getLocalServerInstance ($fallback=CACHE_NONE) |
Factory function for CACHE_ACCEL (referenced from DefaultSettings.php) More... | |
static | getMainStashInstance () |
Get the cache object for the main stash. More... | |
static | getMainWANInstance () |
Get the main WAN cache object. More... | |
static | getWANInstance ($id) |
Get a cached instance of the specified type of WAN cache object. More... | |
static | newAccelerator ($params=[], $fallback=null) |
static | newAnything ($params) |
Factory function for CACHE_ANYTHING (referenced from DefaultSettings.php) More... | |
static | newFromId ($id) |
Create a new cache object of the specified type. More... | |
static | newFromParams ($params) |
Create a new cache object from parameters. More... | |
static | newWANCacheFromId ($id) |
Create a new cache object of the specified type. More... | |
Static Public Attributes | |
static BagOStuff[] | $instances = [] |
Map of (id => BagOStuff) More... | |
static WANObjectCache[] | $wanInstances = [] |
Map of (id => WANObjectCache) More... | |
Functions to get cache objects.
The word "cache" has two main dictionary meanings, and both are used in this factory class. They are:
The former should always use strongly consistent stores, so callers don't have to deal with stale reads. The later may be eventually consistent, but callers can use BagOStuff:READ_LATEST to see the latest available data.
Primary entry points:
All the above cache instances (BagOStuff and WANObjectCache) have their makeKey() method scoped to the current wiki ID. Use makeGlobalKey() to avoid this scoping when using keys that need to be shared amongst wikis.
Definition at line 81 of file ObjectCache.php.
|
static |
Clear all the cached instances.
Definition at line 381 of file ObjectCache.php.
Referenced by MediaWiki\MediaWikiServices\disableStorageBackend(), MediaWikiTestCase\doLightweightServiceReset(), and ForkController\prepareEnvironment().
|
static |
Get the default keyspace for this wiki.
This is either the value of the CachePrefix
configuration variable, or (if the former is unset) the DBname
configuration variable, with DBprefix
(if defined).
Definition at line 143 of file ObjectCache.php.
References $wgCachePrefix, global, and wfWikiID().
|
static |
Get a cached instance of the specified type of cache object.
string | $id | A key in $wgObjectCaches. |
Definition at line 93 of file ObjectCache.php.
Referenced by MediaWiki\Session\SessionManager\__construct(), Installer\__construct(), Preprocessor\cacheGetTree(), Preprocessor\cacheSetTree(), LanguageConverter\loadTables(), wfGetCache(), wfGetMainCache(), wfGetMessageCacheStorage(), and wfGetParserCacheStorage().
|
static |
Get the main cluster-local cache object.
Definition at line 336 of file ObjectCache.php.
References global.
Referenced by LoadMonitorMySQL\__construct(), MediaWiki\Auth\ThrottlePreAuthenticationProvider\__construct(), MediaWiki\Auth\Throttler\__construct(), SwiftFileBackend\__construct(), Pingback\acquireLock(), LoginFormPreAuthManager\addNewAccountInternal(), MediaWiki\Session\SessionManager\autoCreateUser(), MediaWiki\Auth\AuthManager\autoCreateUser(), ApiStashEdit\checkCache(), LoginFormPreAuthManager\clearLoginThrottle(), MediaWiki\Auth\AuthManager\continueAccountCreation(), FileCacheBase\getMissesRecent(), LoginFormPreAuthManager\incrementLoginThrottle(), FileCacheBase\incrMissesRecent(), ApiStashEdit\parseAndStash(), User\pingLimiter(), JobQueueGroup\queuesHaveJobs(), ResourceLoaderModule\saveFileDependencies(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), MediaWiki\Session\SessionManagerTest\testAutoCreateUser(), MediaWiki\Auth\AuthManagerTest\testContinueAccountCreation(), GlobalTest\testWfForeignMemcKey(), GlobalTest\testWfGlobalCacheKey(), GlobalTest\testWfMemcKey(), WikiPage\triggerOpportunisticLinksUpdate(), wfForeignMemcKey(), wfGenerateThumbnail(), wfGlobalCacheKey(), and wfMemcKey().
|
static |
Factory function for CACHE_ACCEL (referenced from DefaultSettings.php)
This will look for any APC style server-local cache. A fallback cache can be specified if none is found.
// Direct calls ObjectCache::getLocalServerInstance( $fallbackType ); // From $wgObjectCaches via newFromParams() ObjectCache::getLocalServerInstance( array( 'fallback' => $fallbackType ) );
int | string | array | $fallback | Fallback cache or parameter map with 'fallback' |
MWException |
Definition at line 261 of file ObjectCache.php.
References $fallback, CACHE_NONE, and wfIniGetBool().
Referenced by FileContentsHasher\__construct(), LoadMonitorMySQL\__construct(), DBLockManager\__construct(), ExtensionRegistry\__construct(), LoadBalancer\__construct(), SwiftFileBackend\__construct(), MessageCache\__construct(), DatabaseBase\__construct(), ResourceLoaderFileModule\compileLessFile(), ResourceLoader\filter(), IcuCollation\getFirstLetterData(), DateFormatter\getInstance(), TransformationalImageHandler\getMagickVersion(), UIDGenerator\getSequentialPerNodeIDs(), TemplateParser\getTemplate(), MWCryptHKDF\singleton(), and wfIsBadImage().
|
static |
Get the cache object for the main stash.
Stash objects are BagOStuff instances suitable for storing light weight data that is not canonically stored elsewhere (such as RDBMS). Stashes should be configured to propagate changes to all data-centers.
Callers should be prepared for:
Definition at line 372 of file ObjectCache.php.
References $wgMainStash, and global.
Referenced by SiteStatsUpdate\adjustPending(), WikiPage\doDeleteArticleReal(), SiteStatsUpdate\getPendingDeltas(), UploadBase\getSessionStatus(), LBFactory\newChronologyProtector(), SiteStatsUpdate\removePendingDeltas(), UploadBase\setSessionStatus(), and Article\showMissingArticle().
|
static |
Get the main WAN cache object.
Definition at line 348 of file ObjectCache.php.
References $wgMainWANCache, and global.
Referenced by JobQueueDB\__construct(), MessageBlobStore\__construct(), LoadBalancer\__construct(), MessageCache\__construct(), Skin\buildSidebar(), FeedUtils\checkPurge(), LocalRepo\checkRedirect(), User\clearSharedCache(), FormatMetadata\fetchExtendedMetadata(), FileBackendGroup\get(), JobQueueGroup\getCachedConfigVar(), ForeignDBFile\getDescriptionText(), File\getDescriptionText(), DifferenceEngine\getDiffBody(), DjVuHandler\getDimensionInfo(), ApiHelp\getHelp(), BacklinkCache\getNumLinks(), ForeignAPIRepo\getThumbUrlFromCache(), User\getTouched(), ForeignAPIRepo\httpGetCached(), InfoAction\invalidateCache(), LocalFile\invalidateCache(), LocalRepo\invalidateImageRedirect(), Block\isWhitelistedFromAutoblocks(), ChangeTags\listExplicitlyDefinedTags(), ChangeTags\listExtensionActivatedTags(), ChangeTags\listExtensionDefinedTags(), ChangesFeed\loadFromCache(), LocalFile\loadFromCache(), User\loadFromCache(), AjaxResponse\loadFromMemcached(), Revision\loadText(), ApiMain\makeHelpMsg(), SiteStats\numberingroup(), InfoAction\pageCounts(), BacklinkCache\partition(), User\purge(), ForeignAPIFile\purgeDescriptionPage(), Article\purgePatrolFooterCache(), ChangeTags\purgeTagCacheAll(), ChangeTags\purgeTagUsageCache(), ForeignAPIFile\purgeThumbnails(), ParserTest\runTest(), ChangesFeed\saveToCache(), LocalFile\saveToCache(), MediaWikiTestCase\setUp(), Article\showPatrolFooter(), AjaxResponse\storeInMemcached(), ChangeTags\tagUsageStatistics(), User\touch(), and ResourceLoaderModule\validateScriptFile().
|
static |
Get a cached instance of the specified type of WAN cache object.
string | $id | A key in $wgWANObjectCaches. |
Definition at line 108 of file ObjectCache.php.
Referenced by WANObjectCacheTest\setUp().
|
static |
array | $params | [optional] Array key 'fallback' for $fallback. |
int | string | $fallback | Fallback cache, e.g. (CACHE_NONE, "hash") (since 1.24) |
Definition at line 285 of file ObjectCache.php.
References $fallback, and $params.
Referenced by LanguageConverter\convertNamespace().
|
static |
Factory function for CACHE_ANYTHING (referenced from DefaultSettings.php)
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.
array | $params |
Definition at line 222 of file ObjectCache.php.
References $e, $wgMessageCacheType, $wgParserCacheType, as, CACHE_ANYTHING, CACHE_DB, CACHE_NONE, and global.
|
static |
Create a new cache object of the specified type.
string | $id | A key in $wgObjectCaches. |
MWException |
Definition at line 123 of file ObjectCache.php.
References $wgObjectCaches, and global.
Referenced by BagOStuffTest\setUp(), and BagOStuffTest\testMakeKey().
|
static |
Create a new cache object from parameters.
array | $params | Must have 'factory' or 'class' property. |
MWException |
Definition at line 165 of file ObjectCache.php.
References $GLOBALS, and $params.
Referenced by MemcLockManager\__construct().
|
static |
Create a new cache object of the specified type.
string | $id | A key in $wgWANObjectCaches. |
MWException |
Definition at line 305 of file ObjectCache.php.
References $params, $wgWANObjectCaches, as, and global.
|
static |
Map of (id => BagOStuff)
Definition at line 83 of file ObjectCache.php.
Referenced by MediaWiki\Session\SessionManagerTest\getManager(), ParserTest\setupDatabase(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), MediaWiki\Session\SessionManagerTest\testAutoCreateUser(), and MediaWiki\Session\SessionManagerTest\testConstructor().
|
static |
Map of (id => WANObjectCache)
Definition at line 85 of file ObjectCache.php.