PHP Class Metaphore\Cache

显示文件 Open project: sobstel/metaphore Class Usage Examples

Protected Properties

Property Type Description
$lockManager * @var \Metaphore\LockManager
$onNoStaleCacheCallable * @var callable
$valueStore * @var \Metaphore\Store\ValueStoreInterface

Public Methods

Method Description
__construct ( Metaphore\Store\ValueStoreInterface $valueStore, LockManager $lockManager = null )
cache ( $key, callable $cachedCallable, $ttl, callable $onNoStaleCacheCallable = null ) Caches specified closure/method/function for specified time.
delete ( $key ) : boolean
getLockManager ( ) : LockManager
getValue ( $key ) : Value
getValueStore ( ) : Metaphore\Store\ValueStoreInterface
onNoStaleCache ( callable $onNoStaleCacheCallable )
setResult ( $key, $result, $ttl ) Sets result. Does not use anti-dogpile-effect mechanism. Use cache() instead for this.

Method Details

__construct() public method

public __construct ( Metaphore\Store\ValueStoreInterface $valueStore, LockManager $lockManager = null )
$valueStore Metaphore\Store\ValueStoreInterface
$lockManager LockManager

cache() public method

As a third argument - instead of integer - you can pass Ttt object to define grace tll and lock ttl (both optional).
public cache ( $key, callable $cachedCallable, $ttl, callable $onNoStaleCacheCallable = null )
$cachedCallable callable
$onNoStaleCacheCallable callable

delete() public method

public delete ( $key ) : boolean
return boolean

getLockManager() public method

public getLockManager ( ) : LockManager
return LockManager

getValue() public method

public getValue ( $key ) : Value
return Value

getValueStore() public method

public getValueStore ( ) : Metaphore\Store\ValueStoreInterface
return Metaphore\Store\ValueStoreInterface

onNoStaleCache() public method

public onNoStaleCache ( callable $onNoStaleCacheCallable )
$onNoStaleCacheCallable callable

setResult() public method

Sets result. Does not use anti-dogpile-effect mechanism. Use cache() instead for this.
public setResult ( $key, $result, $ttl )

Property Details

$lockManager protected_oe property

* @var \Metaphore\LockManager
protected $lockManager

$onNoStaleCacheCallable protected_oe property

* @var callable
protected $onNoStaleCacheCallable

$valueStore protected_oe property

* @var \Metaphore\Store\ValueStoreInterface
protected $valueStore