25 $this->wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
36 return $this->wanCache->getWithSetCallback(
39 function ( $oldValue, &$ttl, array &$setOpts ) {
41 $setOpts += Database::getCacheSetOptions(
$dbr );
43 return $dbr->selectFieldValues(
46 [
'page_namespace' => NS_GADGET_DEFINITION ],
51 'checkKeys' => [ $key ],
52 'pcTTL' => WANObjectCache::TTL_PROC_SHORT,
62 if ( $target->
inNamespace( NS_GADGET_DEFINITION ) ) {
71 if ( $target->
inNamespace( NS_GADGET_DEFINITION ) ) {
80 if ( $target->
inNamespace( NS_GADGET_DEFINITION ) ) {
100 $gadget = $this->wanCache->getWithSetCallback(
106 function ( $old, &$ttl, array &$setOpts ) use ( $id ) {
108 $title = Title::makeTitleSafe( NS_GADGET_DEFINITION, $id );
110 $ttl = WANObjectCache::TTL_UNCACHEABLE;
114 $rev = Revision::newFromTitle( $title );
116 $ttl = WANObjectCache::TTL_UNCACHEABLE;
120 $content =
$rev->getContent();
123 $ttl = WANObjectCache::TTL_UNCACHEABLE;
130 'checkKeys' => [ $key ],
131 'pcTTL' => WANObjectCache::TTL_PROC_SHORT,
136 if ( $gadget ===
null ) {
137 throw new InvalidArgumentException(
"No gadget registered for '$id'" );
156 return $this->wanCache->makeKey(
'gadgets',
'namespace',
'ids' );
164 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,...
handlePageDeletion(LinkTarget $target)
@inheritDoc
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.
handlePageCreation(LinkTarget $target)
@inheritDoc
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.
handlePageUpdate(LinkTarget $target)
@inheritDoc
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.
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