25 $this->wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
37 return $this->wanCache->getWithSetCallback(
40 function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
42 $setOpts += Database::getCacheSetOptions(
$dbr );
44 return $dbr->selectFieldValues(
47 [
'page_namespace' => NS_GADGET_DEFINITION ],
52 'checkKeys' => [ $key ],
53 'pcTTL' => WANObjectCache::TTL_PROC_SHORT,
63 if ( $target->
inNamespace( NS_GADGET_DEFINITION ) ) {
72 if ( $target->
inNamespace( NS_GADGET_DEFINITION ) ) {
81 if ( $target->
inNamespace( NS_GADGET_DEFINITION ) ) {
101 $gadget = $this->wanCache->getWithSetCallback(
104 function ( $old, &$ttl, array &$setOpts ) use ( $id ) {
106 $title = Title::makeTitleSafe( NS_GADGET_DEFINITION, $id );
108 $ttl = WANObjectCache::TTL_UNCACHEABLE;
112 $rev = Revision::newFromTitle(
$title );
114 $ttl = WANObjectCache::TTL_UNCACHEABLE;
121 $ttl = WANObjectCache::TTL_UNCACHEABLE;
128 'checkKeys' => [ $key ],
129 'pcTTL' => WANObjectCache::TTL_PROC_SHORT,
134 if ( $gadget ===
null ) {
135 throw new InvalidArgumentException(
"No gadget registered for '$id'" );
154 return $this->wanCache->makeKey(
'gadgets',
'namespace',
'ids' );
162 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)
Given that the provided page was updated, invalidate caches if necessary.void
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)
Given that the provided page was created, invalidate caches if necessary.void
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)
Given that the provided page was updated, invalidate caches if necessary.void
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.