40 $this->value = $value;
42 if ( !is_array( $deps ) ) {
55 foreach ( $this->deps as $dep ) {
56 if ( $dep->isExpired() ) {
69 foreach ( $this->deps as $dep ) {
70 $dep->loadDependencyValues();
91 $cache->set( $key, $this, $expiry );
112 $callbackParams = [], $deps = []
114 $obj = $cache->get( $key );
117 $value = $obj->value;
118 } elseif ( $callback ) {
119 $value = $callback( ...$callbackParams );
120 # Cache the newly-generated value
122 $wrapper->storeToCache( $cache, $key, $expiry );
Base class to represent dependencies for LocalisationCache entries.
Store an arbitrary value whilst representing several CacheDependency objects as one.
__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.