PHP Interface PDepend\Util\Cache\CacheDriver

Since: 0.10.0
Show file Open project: pdepend/pdepend Interface Usage Examples

Public Methods

Method Description
remove ( string $pattern ) : void This method will remove an existing cache entry for the given identifier.
restore ( string $key, string $hash = null ) : mixed This method tries to restore an existing cache entry for the given $key. If a matching entry exists, this method verifies that the given $hash and the the value stored with cache entry are equal.
store ( string $key, mixed $data, string $hash = null ) : void This method will store the given $data under $key. This method can be called with a third parameter that will be used as a verification token, when the a cache entry gets restored. If the stored hash and the supplied hash are not identical, that cache entry will be removed and not returned.
type ( string $type ) : PDepend\Util\Cache\CacheDriver Sets the type for the next store() or restore() method call. A type is something like a namespace or group for cache entries.

Method Details

remove() public method

It will delete all cache entries where the cache key start with the given $pattern. If no matching entry exists, this method simply does nothing.
public remove ( string $pattern ) : void
$pattern string The cache key pattern.
return void

restore() public method

Then it returns the cached entry. Otherwise this method will return NULL.
public restore ( string $key, string $hash = null ) : mixed
$key string The cache key for the given data.
$hash string Optional hash that will be used for verification.
return mixed

store() public method

This method will store the given $data under $key. This method can be called with a third parameter that will be used as a verification token, when the a cache entry gets restored. If the stored hash and the supplied hash are not identical, that cache entry will be removed and not returned.
public store ( string $key, mixed $data, string $hash = null ) : void
$key string The cache key for the given data.
$data mixed Any data that should be cached.
$hash string Optional hash that will be used for verification.
return void

type() public method

Note that the cache type will be reset after each storage method call, so you must invoke right before every call to restore() or store().
public type ( string $type ) : PDepend\Util\Cache\CacheDriver
$type string
return PDepend\Util\Cache\CacheDriver