Cache
The Backyard caching classes are a copy of Steve Grunwell's wp-cache-remember repository repository but wrapped into a class.
The wrapper exists only for compatibility with the php-scoper tool which sometimes may have issues with global functions.
Remember a transient
Retrieve a value from transients. If it doesn't exist, run the callback to generate and cache the value.
$cached = \Backyard\Cache\Transient::remember( 'transient_key_here', function() {
$data = do_some_processing_here();
return $data;
} );
Forget a transient
Retrieve and subsequently delete a value from the transient cache.
\Backyard\Cache\Transient::forget( 'transient_key_here' );
Get a transient
Get a transient from the database.
$value = \Backyard\Cache\Transient::get( 'transient_key_here' );
Object cache remember
Retrieve a value from the object cache. If it doesn't exist, run the callback to generate and cache the value.
$cached = \Backyard\Cache\ObjectCache::remember( 'key_here', function() {
return 'some value;
} );
Object cache forget
Retrieve and subsequently delete a value from the object cache.
$value = \Backyard\Cache\ObjectCache::forget( 'key_here' );