PHP Class PHPDaemon\Cache\CappedStorage

Author: Vasily Zorin ([email protected])
Inheritance: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog
Show file Open project: kakserpom/phpdaemon

Public Properties

Property Type Description
$cache Storage of cached items
$capWindow Additional window to decrease number of sorter calls
$maxCacheSize Maximum number of cached elements
$sorter Sorter function

Public Methods

Method Description
get ( string $key ) : object Gets element by key
getValue ( string $key ) : mixed Gets value of element by key
hash ( string $key ) : integer Hash function
invalidate ( string $key ) : void Invalidates cache element
put ( string $key, mixed $value, integer $ttl = null ) : mixed Puts element in cache
setCapWindow ( integer $w ) : void Sets cap window
setMaxCacheSize ( integer $size ) : void Sets cache size

Method Details

get() public method

Gets element by key
public get ( string $key ) : object
$key string Key
return object Item

getValue() public method

Gets value of element by key
public getValue ( string $key ) : mixed
$key string Key
return mixed

hash() public method

Hash function
public hash ( string $key ) : integer
$key string Key
return integer

invalidate() public method

Invalidates cache element
public invalidate ( string $key ) : void
$key string Key
return void

put() public method

Puts element in cache
public put ( string $key, mixed $value, integer $ttl = null ) : mixed
$key string Key
$value mixed Value
$ttl integer Time to live
return mixed

setCapWindow() public method

Sets cap window
public setCapWindow ( integer $w ) : void
$w integer Additional window to decrease number of sorter calls
return void

setMaxCacheSize() public method

Sets cache size
public setMaxCacheSize ( integer $size ) : void
$size integer Maximum number of elements
return void

Property Details

$cache public property

Storage of cached items
public $cache

$capWindow public property

Additional window to decrease number of sorter calls
public $capWindow

$maxCacheSize public property

Maximum number of cached elements
public $maxCacheSize

$sorter public property

Sorter function
public $sorter