Class Access
Provides a standardized cache access
Methods summary
public
|
#
__construct( Stash\Interfaces\PoolInterface $pool )
__construct
Parameters
- $pool
- $pool cache pool to use for this cache instance
|
public
boolean
|
#
write( string|string[] $key, mixed $value, integer|DateTime|null $ttl = null )
Write data for key into cache.
Write data for key into cache.
Parameters
- $key
- Identifier for the cache item
- $value
- Data to be cached - anything except a resource
- $ttl
time to live, integer for ttl in seconds,
DateTime object to expire at a specific time,
or null for
Returns
boolean True if the data was successfully cached, false on failure
|
public
mixed
|
#
read( string|string[] $key )
Read a key from the cache.
Read a key from the cache.
Parameters
- $key
- Identifier for the cache item
Returns
mixed The cached data
|
public
boolean
|
#
delete( string|string[] $key )
Delete a key from the cache.
Delete a key from the cache.
Parameters
- $key
- Identifier for the cache item
Returns
boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed
|
public
mixed
|
#
cacheRead( string|string[] $cacheKey, callable $regenFunction, integer|DateTime|null $ttl = null, mixed $args = null )
cache block wrapper using Invalidation::PRECOMPUTE
cache block wrapper using Invalidation::PRECOMPUTE
If the cache read for $key is a miss, call the $regenFunction to update it.
With the PRECOMPUTE strategy, it will trigger a miss on a read on one caller
before the cache expires, so it will be done in advance.
Parameters
- $cacheKey
- Identifier for the cache item
- $regenFunction
- function to generate cached content
- $ttl
time to live, number ofseconds as integer,
DateTime to expire at a specific time,
or null for default
- $args
- $args variable argument list for $regenFunction
Returns
mixed
|
public
|
#
garbageCollect( )
Garbage collection - remove all expired and deleted data
Garbage collection - remove all expired and deleted data
|
public
boolean
|
#
clear( )
clear all keys and data from the cache.
clear all keys and data from the cache.
Returns
boolean True if the cache was successfully cleared, false otherwise
|
public
Stash\Interfaces\PoolInterface
|
#
pool( )
direct access to pool
WARNING: this is intended for diagnostics and similar advanced uses.
Depending on direct access to the pool may break future compatibility.
Returns
Stash\Interfaces\PoolInterface the current pool
|
Properties summary
protected
Stash\Interfaces\PoolInterface
|
$pool
|
|