23 $this->wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
34 return $this->wanCache->getWithSetCallback(
37 function ( $oldValue, &$ttl, array &$setOpts ) {
39 $setOpts += Database::getCacheSetOptions(
$dbr );
41 return $dbr->selectFieldValues(
44 [
'page_namespace' => NS_GADGET_DEFINITION ],
49 'checkKeys' => [ $key ],
50 'pcTTL' => WANObjectCache::TTL_PROC_SHORT,
70 $gadget = $this->wanCache->getWithSetCallback(
73 function ( $old, &$ttl, array &$setOpts ) use ( $id ) {
75 $title = Title::makeTitleSafe( NS_GADGET_DEFINITION, $id );
77 $ttl = WANObjectCache::TTL_UNCACHEABLE;
83 $ttl = WANObjectCache::TTL_UNCACHEABLE;
87 $content =
$rev->getContent();
90 $ttl = WANObjectCache::TTL_UNCACHEABLE;
97 'checkKeys' => [ $key ],
98 'pcTTL' => WANObjectCache::TTL_PROC_SHORT,
103 if ( $gadget ===
null ) {
104 throw new InvalidArgumentException(
"No gadget registered for '$id'" );
123 return $this->wanCache->makeKey(
'gadgets',
'namespace',
'ids' );
131 return $this->wanCache->makeKey(
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
GadgetRepo implementation where each gadget has a page in the Gadget definition namespace,...
const CACHE_TTL
How long in seconds the list of gadget ids and individual gadgets should be cached for (1 day)
getGadgetIds()
Get a list of gadget ids from cache/database.
purgeGadgetEntry( $id)
Update the cache for a specific Gadget whenever it is updated.
purgeGadgetIdsList()
Purge the list of gadget ids when a page is deleted or if a new page is created.
const GADGET_CLASS_VERSION
Increment this when changing class structure.
static newFromDefinitionContent( $id, GadgetDefinitionContent $content)
Create a object based on the metadata in a GadgetDefinitionContent object.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
Multi-datacenter aware caching interface.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev