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(
107 function ( $old, &$ttl,
array &$setOpts ) use ( $id ) {
109 $title = Title::makeTitleSafe( NS_GADGET_DEFINITION, $id );
111 $ttl = WANObjectCache::TTL_UNCACHEABLE;
117 $ttl = WANObjectCache::TTL_UNCACHEABLE;
124 $ttl = WANObjectCache::TTL_UNCACHEABLE;
131 'checkKeys' => [ $key ],
132 'pcTTL' => WANObjectCache::TTL_PROC_SHORT,
137 if ( $gadget ===
null ) {
138 throw new InvalidArgumentException(
"No gadget registered for '$id'" );
157 return $this->wanCache->makeKey(
'gadgets',
'namespace',
'ids' );
165 return $this->wanCache->makeKey(
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
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.
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))