68 parent::afterExecute( $subPage );
91 if ( !isset( $this->cacheHelper ) ) {
94 $this->cacheHelper->setCacheEnabled( $this->cacheEnabled );
95 $this->cacheHelper->setOnInitializedHandler( [ $this,
'onCacheInitialized' ] );
99 if ( array_key_exists(
'action', $keyArgs ) && $keyArgs[
'action'] ===
'purge' ) {
100 unset( $keyArgs[
'action'] );
103 $this->cacheHelper->setCacheKey( $keyArgs );
105 if ( $this->
getRequest()->getText(
'action' ) ===
'purge' ) {
106 $this->cacheHelper->rebuildOnDemand();
110 $this->cacheHelper->startCache( $cacheExpiry,
$cacheEnabled );
128 return $this->cacheHelper->getCachedValue( $computeFunction,
$args, $key );
144 $this->
getOutput()->addHTML( $this->cacheHelper->getCachedValue(
158 if ( isset( $this->cacheHelper ) ) {
159 $this->cacheHelper->saveCache();
172 $this->cacheHelper->setExpiry( $cacheExpiry );
198 $this->
getOutput()->setSubtitle( $this->cacheHelper->getCachedNotice( $this->getContext() ) );
Helper class for caching various elements in a single cache entry.
onCacheInitialized( $hasCached)
Gets called after the cache got initialized.
startCache( $cacheExpiry=null, $cacheEnabled=null)
Initializes the caching.
bool $cacheEnabled
If the cache is enabled or not.
afterExecute( $subPage)
Gets called after.
getCachedValue( $computeFunction, $args=[], $key=null)
Get a cached value if available or compute it if not and then cache it if possible.
CacheHelper $cacheHelper
CacheHelper object to which we forward the non-SpecialPage specific caching work.
saveCache()
Saves the HTML to the cache in case it got recomputed.
setCacheEnabled( $cacheEnabled)
Sets if the cache should be enabled or not.
addCachedHTML( $computeFunction, $args=[], $key=null)
Add some HTML to be cached.
setExpiry( $cacheExpiry)
Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry.
getCacheKey()
Returns the variables used to constructed the cache key in an array.
Parent class for all special pages.
getOutput()
Get the OutputPage being used for this instance.
getRequest()
Get the WebRequest being used for this instance.
getLanguage()
Shortcut to get user's language.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Interface for all classes implementing CacheHelper functionality.