[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
Abstract special page class with scaffolding for caching HTML and other values in a single blob. Before using any of the caching functionality, call startCache. After the last call to either getCachedValue or addCachedHTML, call saveCache.
Author: | Jeroen De Dauw < [email protected] > |
File Size: | 201 lines (6 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
afterExecute( $subPage ) X-Ref |
Gets called after @see SpecialPage::execute. param: string|null $subPage |
setCacheEnabled( $cacheEnabled ) X-Ref |
Sets if the cache should be enabled or not. param: bool $cacheEnabled |
startCache( $cacheExpiry = null, $cacheEnabled = null ) X-Ref |
Initializes the caching. Should be called before the first time anything is added via addCachedHTML. param: int|null $cacheExpiry Sets the cache expiry, either ttl in seconds or unix timestamp. param: bool|null $cacheEnabled Sets if the cache should be enabled or not. |
getCachedValue( $computeFunction, $args = array() X-Ref |
Get a cached value if available or compute it if not and then cache it if possible. The provided $computeFunction is only called when the computation needs to happen and should return a result value. $args are arguments that will be passed to the compute function when called. param: callable $computeFunction param: array|mixed $args param: string|null $key return: mixed |
addCachedHTML( $computeFunction, $args = array() X-Ref |
Add some HTML to be cached. This is done by providing a callback function that should return the HTML to be added. It will only be called if the item is not in the cache yet or when the cache has been invalidated. param: callable $computeFunction param: array $args param: string|null $key |
saveCache() X-Ref |
Saves the HTML to the cache in case it got recomputed. Should be called after the last time anything is added via addCachedHTML. |
setExpiry( $cacheExpiry ) X-Ref |
Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry. param: int $cacheExpiry |
getCacheKey() X-Ref |
Returns the variables used to constructed the cache key in an array. return: array |
onCacheInitialized( $hasCached ) X-Ref |
Gets called after the cache got initialized. param: bool $hasCached |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |