[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/cache/ -> CacheHelper.php (summary)

Cache of various elements in a single cache entry. 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] >
License: GNU GPL v2 or later
File Size: 386 lines (10 kb)
Included or required:0 times
Referenced: 2 times
Includes or requires: 0 files

Defines 2 classes

ICacheHelper:: (5 methods):
  setCacheEnabled()
  startCache()
  getCachedValue()
  saveCache()
  setExpiry()

CacheHelper:: (11 methods):
  setCacheEnabled()
  startCache()
  getCachedNotice()
  initCaching()
  getCachedValue()
  saveCache()
  setExpiry()
  getCacheKeyString()
  setCacheKey()
  rebuildOnDemand()
  setOnInitializedHandler()


Interface: ICacheHelper  - X-Ref

Interface for all classes implementing CacheHelper functionality.

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

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

Class: CacheHelper  - X-Ref

Helper class for caching various elements in a single cache entry.

To get a cached value or compute it, use getCachedValue like this:
$this->getCachedValue( $callback );

To add HTML that should be cached, use addCachedHTML like this:
$this->addCachedHTML( $callback );

The callback function is only called when needed, so do all your expensive
computations here. This function should returns the HTML to be cached.
It should not add anything to the PageOutput object!

Before the first addCachedHTML call, you should call $this->startCache();
After adding the last HTML that should be cached, call $this->saveCache();

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.

getCachedNotice( IContextSource $context, $includePurgeLink = true )   X-Ref
Returns a message that notifies the user he/she is looking at
a cached version of the page, including a refresh link.

param: IContextSource $context
param: bool $includePurgeLink
return: string

initCaching()   X-Ref
Initializes the caching if not already done so.
Should be called before any of the caching functionality is used.


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

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

getCacheKeyString()   X-Ref
Returns the cache key to use to cache this page's HTML output.
Is constructed from the special page name and language code.

return: string

setCacheKey( array $cacheKey )   X-Ref
Sets the cache key that should be used.

param: array $cacheKey

rebuildOnDemand()   X-Ref
Rebuild the content, even if it's already cached.
This effectively has the same effect as purging the cache,
since it will be overridden with the new value on the next request.


setOnInitializedHandler( $handlerFunction )   X-Ref
Sets a function that gets called when initialization of the cache is done.

param: callable $handlerFunction



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1