MediaWiki REL1_33
ICacheHelper Interface Reference

Interface for all classes implementing CacheHelper functionality. More...

Inheritance diagram for ICacheHelper:

Public Member Functions

 getCachedValue ( $computeFunction, $args=[], $key=null)
 Get a cached value if available or compute it if not and then cache it if possible.
 
 saveCache ()
 Saves the HTML to the cache in case it got recomputed.
 
 setCacheEnabled ( $cacheEnabled)
 Sets if the cache should be enabled or not.
 
 setExpiry ( $cacheExpiry)
 Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry...
 
 startCache ( $cacheExpiry=null, $cacheEnabled=null)
 Initializes the caching.
 

Detailed Description

Interface for all classes implementing CacheHelper functionality.

Since
1.20

Definition at line 30 of file ICacheHelper.php.

Member Function Documentation

◆ getCachedValue()

ICacheHelper::getCachedValue ( $computeFunction,
$args = [],
$key = null )

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.

Since
1.20
Parameters
callable$computeFunction
array | mixed$args
string | null$key
Returns
mixed

Implemented in CachedAction, CacheHelper, and SpecialCachedPage.

◆ saveCache()

ICacheHelper::saveCache ( )

Saves the HTML to the cache in case it got recomputed.

Should be called after the last time anything is added via addCachedHTML.

Since
1.20

Implemented in CachedAction, CacheHelper, and SpecialCachedPage.

◆ setCacheEnabled()

ICacheHelper::setCacheEnabled ( $cacheEnabled)

Sets if the cache should be enabled or not.

Since
1.20
Parameters
bool$cacheEnabled

Implemented in CachedAction, CacheHelper, and SpecialCachedPage.

◆ setExpiry()

ICacheHelper::setExpiry ( $cacheExpiry)

Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry...

Since
1.20
Parameters
int$cacheExpiry

Implemented in CachedAction, CacheHelper, and SpecialCachedPage.

◆ startCache()

ICacheHelper::startCache ( $cacheExpiry = null,
$cacheEnabled = null )

Initializes the caching.

Should be called before the first time anything is added via addCachedHTML.

Since
1.20
Parameters
int | null$cacheExpirySets the cache expiry, either ttl in seconds or unix timestamp.
bool | null$cacheEnabledSets if the cache should be enabled or not.

Implemented in CachedAction, CacheHelper, and SpecialCachedPage.


The documentation for this interface was generated from the following file: