43 if ( !is_array(
$deps ) ) {
56 foreach ( $this->deps as $dep ) {
57 if ( $dep->isExpired() ) {
70 foreach ( $this->deps as $dep ) {
71 $dep->loadDependencyValues();
92 $cache->set( $key, $this, $expiry );
113 $callbackParams = [],
$deps = []
115 $obj =
$cache->get( $key );
119 } elseif ( $callback ) {
120 $value = $callback( ...$callbackParams );
121 # Cache the newly-generated value
123 $wrapper->storeToCache(
$cache, $key, $expiry );
This class stores an arbitrary value along with its dependencies.
__construct( $value=false, $deps=[])
initialiseDeps()
Initialise dependency values in preparation for storing.
static getValueFromCache( $cache, $key, $expiry=0, $callback=false, $callbackParams=[], $deps=[])
Attempt to get a value from the cache.
storeToCache( $cache, $key, $expiry=0)
Store the wrapper to a cache.
getValue()
Get the user-defined value.
isExpired()
Returns true if any of the dependencies have expired.