PHP Class Webiny\Component\Cache\Storage\SessionArray

Holds cache in internal array.
Inheritance: implements Webiny\Component\Cache\Bridge\CacheStorageInterface
Mostrar archivo Open project: Webiny/Framework

Public Methods

Method Description
acquireKey ( string $key, &$autoUnlocker ) : boolean Try to lock key, and if key is already locked - wait, until key will be unlocked.
add ( string $key, mixed $value, integer $ttl = 600, array | string $tags = null ) : boolean Save a value into memory only if it DOESN'T exists (or false will be returned).
delete ( string | array $key ) : boolean | array Delete key or array of keys from storage.
deleteByTags ( array | string $tag ) : boolean Delete keys by tags.
deleteOld ( ) : boolean Delete expired cache values.
increment ( string $key, mixed $byValue = 1, integer $limitKeysCount, integer $ttl = 259200 ) : integer | string | array Increment value of the key.
lockKey ( mixed $key, mixed &$autoUnlockerVariable ) : boolean Get exclusive mutex for key. Key will be still accessible to read and write, but another process can exclude dog-pile effect, if before updating the key he will try to get this mutex.
read ( string | array $key, mixed &$ttlLeft ) : mixed Get the cache data for the given $key.
save ( string $key, mixed $value, integer $ttl = 600, array | string $tags = null ) : boolean Save a value into memory.
selectByCallback ( callable $callback, boolean $getArray = false ) : mixed Select from storage via callback function.

Method Details

acquireKey() public method

Time of waiting is defined in max_wait_unlock constant of MemoryObject class.
public acquireKey ( string $key, &$autoUnlocker ) : boolean
$key string Name of the cache key.
$autoUnlocker
return boolean

add() public method

Save a value into memory only if it DOESN'T exists (or false will be returned).
public add ( string $key, mixed $value, integer $ttl = 600, array | string $tags = null ) : boolean
$key string Name of the key.
$value mixed Value you wish to save.
$ttl integer For how long to store value. (in seconds)
$tags array | string Tags you wish to assign to this cache entry.
return boolean True if value was added, otherwise false.

delete() public method

Delete key or array of keys from storage.
public delete ( string | array $key ) : boolean | array
$key string | array Key, or array of keys, you wish to delete.
return boolean | array If array of keys was passed, on error will be returned array of not deleted keys, or true on success.

deleteByTags() public method

Delete keys by tags.
public deleteByTags ( array | string $tag ) : boolean
$tag array | string Tag, or an array of tags, for which you wish to delete the cache.
return boolean

deleteOld() public method

Delete expired cache values.
public deleteOld ( ) : boolean
return boolean

increment() public method

Increment value of the key.
public increment ( string $key, mixed $byValue = 1, integer $limitKeysCount, integer $ttl = 259200 ) : integer | string | array
$key string Name of the cache key.
$byValue mixed If stored value is an array: - If $by_value is a value in array, new element will be pushed to the end of array, - If $by_value is a key=>value array, new key=>value pair will be added (or updated).
$limitKeysCount integer Maximum count of elements (used only if stored value is array).
$ttl integer Set time to live for key.
return integer | string | array New key value.

lockKey() public method

Get exclusive mutex for key. Key will be still accessible to read and write, but another process can exclude dog-pile effect, if before updating the key he will try to get this mutex.
public lockKey ( mixed $key, mixed &$autoUnlockerVariable ) : boolean
$key mixed Name of the cache key.
$autoUnlockerVariable mixed Pass empty, just declared variable
return boolean

read() public method

Get the cache data for the given $key.
public read ( string | array $key, mixed &$ttlLeft ) : mixed
$key string | array Name of the cache key.
$ttlLeft mixed = (ttl - time()) of key. Use to exclude dog-pile effect, with lock/unlock_key methods.
return mixed

save() public method

Save a value into memory.
public save ( string $key, mixed $value, integer $ttl = 600, array | string $tags = null ) : boolean
$key string Name of the key.
$value mixed Value you wish to save.
$ttl integer For how long to store value. (in seconds)
$tags array | string Tags you wish to assign to this cache entry.
return boolean True if value was stored successfully, otherwise false.

selectByCallback() public method

Only values of array type will be selected.
public selectByCallback ( callable $callback, boolean $getArray = false ) : mixed
$callback callable ($value_array,$key)
$getArray boolean
return mixed