[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/actions/ -> CachedAction.php (summary)

Abstract action class with scaffolding for caching HTML and other values in a single blob. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Author: Jeroen De Dauw < [email protected] >
File Size: 189 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 8 functions

  setCacheEnabled()
  startCache()
  getCachedValue()
  addCachedHTML()
  saveCache()
  setExpiry()
  getCacheKey()
  onCacheInitialized()

Functions
Functions that are not part of a class:

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