MediaWiki
1.30.0
|
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 | 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 | newWANCacheFromParams (array $params) |
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 latter 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 80 of file ObjectCache.php.
|
static |
Clear all the cached instances.
Definition at line 400 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 149 of file ObjectCache.php.
References $wgCachePrefix, global, and wfWikiID().
Referenced by newFromParams().
|
static |
Get a cached instance of the specified type of cache object.
string | $id | A key in $wgObjectCaches. |
Definition at line 92 of file ObjectCache.php.
References newFromId().
Referenced by MediaWiki\Session\SessionManager\__construct(), Installer\__construct(), getLocalClusterInstance(), getLocalServerInstance(), newAnything(), and ManageJobs\repushAbandoned().
|
static |
Get the main cluster-local cache object.
Definition at line 357 of file ObjectCache.php.
References getInstance(), and global.
Referenced by MediaWiki\Auth\ThrottlePreAuthenticationProvider\__construct(), MediaWiki\Auth\Throttler\__construct(), Pingback\acquireLock(), MWLBFactory\applyDefaultConfig(), MediaWiki\Auth\AuthManager\autoCreateUser(), Preprocessor\cacheGetTree(), Preprocessor\cacheSetTree(), ApiStashEdit\checkCache(), MediaWiki\Auth\AuthManager\continueAccountCreation(), WANCacheReapUpdate\doUpdate(), ApiStashEdit\execute(), SpamBlacklist\filter(), FileCacheBase\getMissesRecent(), ApiStashEdit\getStashKey(), SimpleCaptcha\increaseBadLoginCounter(), FileCacheBase\incrMissesRecent(), SimpleCaptcha\isBadLoginPerUserTriggered(), SimpleCaptcha\isBadLoginTriggered(), BotPassword\login(), ApiStashEdit\parseAndStash(), User\pingLimiter(), JobQueueGroup\push(), JobQueueGroup\queuesHaveJobs(), SimpleCaptcha\resetBadLoginCounter(), ResourceLoaderModule\saveFileDependencies(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), MediaWiki\Auth\AuthManagerTest\testContinueAccountCreation(), GlobalTest\testWfForeignMemcKey(), GlobalTest\testWfGlobalCacheKey(), GlobalTest\testWfMemcKey(), WikiPage\triggerOpportunisticLinksUpdate(), and wfGenerateThumbnail().
|
static |
Factory function for CACHE_ACCEL (referenced from DefaultSettings.php)
This will look for any APC or APCu 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( [ 'fallback' => $fallbackType ] );
int | string | array | $fallback | Fallback cache or parameter map with 'fallback' |
InvalidArgumentException |
Definition at line 288 of file ObjectCache.php.
References $cache, $fallback, CACHE_NONE, and getInstance().
Referenced by FileContentsHasher\__construct(), ResourceLoaderFileModule\compileLessFile(), FileBackendGroup\config(), LockManagerGroup\get(), IcuCollation\getFirstLetterData(), DateFormatter\getInstance(), and MediaWikiGadgetsDefinitionRepo\loadGadgets().
|
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 393 of file ObjectCache.php.
Referenced by CaptchaCacheStore\clear(), CaptchaCacheStore\retrieve(), and CaptchaCacheStore\store().
|
static |
Get the main WAN cache object.
Definition at line 370 of file ObjectCache.php.
Referenced by JobQueueDB\__construct(), MessageBlobStore\__construct(), FeedUtils\checkPurge(), LocalRepo\checkRedirect(), BaseBlacklist\clearCache(), User\clearSharedCache(), WANCacheReapUpdate\doUpdate(), JobQueueGroup\getCachedConfigVar(), WikiPage\getContentModel(), SpamBlacklist\getCurrentLinks(), ForeignDBFile\getDescriptionText(), File\getDescriptionText(), DifferenceEngine\getDiffBody(), PdfHandler\getDimensionInfo(), DjVuHandler\getDimensionInfo(), BaseBlacklist\getLocalBlacklists(), BacklinkCache\getNumLinks(), BaseBlacklist\getSharedBlacklists(), ForeignAPIRepo\getThumbUrlFromCache(), BaseBlacklist\getWhitelists(), SimpleCaptcha\getWikiIPWhitelist(), ForeignAPIRepo\httpGetCached(), TitleBlacklist\invalidate(), LocalFile\invalidateCache(), LocalRepo\invalidateImageRedirect(), ResourceLoaderWikiModule\invalidateModuleCache(), LinkCache\invalidateTitle(), TitleBlacklist\load(), ChangesFeed\loadFromCache(), LocalFile\loadFromCache(), User\loadFromCache(), AjaxResponse\loadFromMemcached(), Title\loadRestrictions(), Revision\loadText(), TitleBlacklist\loadWhitelist(), TitleBlacklistEntry\matches(), CiteHooks\onLinksUpdate(), CiteHooks\onLinksUpdateComplete(), ConfirmEditHooks\onPageContentSaveComplete(), BacklinkCache\partition(), ResourceLoaderWikiModule\preloadTitleInfo(), User\purge(), ForeignAPIFile\purgeDescriptionPage(), ForeignAPIFile\purgeThumbnails(), ChangesFeed\saveToCache(), MediaWikiTestCase\setUp(), AjaxResponse\storeInMemcached(), ApiQueryWatchlistRawIntegrationTest\testOwnerAndTokenParams(), 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 107 of file ObjectCache.php.
References newWANCacheFromId().
|
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 245 of file ObjectCache.php.
References $cache, $wgMessageCacheType, $wgParserCacheType, as, CACHE_ANYTHING, CACHE_DB, CACHE_NONE, getInstance(), and global.
Referenced by ObjectCacheTest\testNewAnythingAccel(), ObjectCacheTest\testNewAnythingHash(), ObjectCacheTest\testNewAnythingNoAccel(), ObjectCacheTest\testNewAnythingNoAccelNoDb(), ObjectCacheTest\testNewAnythingNothing(), and ObjectCacheTest\testNewAnythingNothingNoDb().
|
static |
Create a new cache object of the specified type.
string | $id | A key in $wgObjectCaches. |
InvalidArgumentException |
Definition at line 122 of file ObjectCache.php.
References $wgObjectCaches, CACHE_NONE, global, and newFromParams().
Referenced by getInstance(), BagOStuffTest\setUp(), and BagOStuffTest\testMakeKey().
|
static |
Create a new cache object from parameters.
array | $params | Must have 'factory' or 'class' property. |
InvalidArgumentException |
Definition at line 171 of file ObjectCache.php.
References $GLOBALS, $params, as, class, and getDefaultKeyspace().
Referenced by newFromId(), and newWANCacheFromParams().
|
static |
Create a new cache object of the specified type.
string | $id | A key in $wgWANObjectCaches. |
UnexpectedValueException |
Definition at line 308 of file ObjectCache.php.
References $params, $wgObjectCaches, $wgWANObjectCaches, global, and newWANCacheFromParams().
Referenced by getWANInstance().
|
static |
Create a new cache object of the specified type.
array | $params |
UnexpectedValueException |
Definition at line 334 of file ObjectCache.php.
References $params, as, and newFromParams().
Referenced by newWANCacheFromId().
|
static |
Map of (id => BagOStuff)
Definition at line 82 of file ObjectCache.php.
Referenced by MediaWiki\Session\SessionManagerTest\getManager(), CaptchaPreAuthenticationProviderTest\setUp(), MediaWiki\Auth\AuthManagerTest\testAutoAccountCreation(), and MediaWiki\Session\SessionManagerTest\testConstructor().
|
static |
Map of (id => WANObjectCache)
Definition at line 84 of file ObjectCache.php.