PHP Класс Jamm\Memory\Shm\SingleMemory

Наследование: extends Jamm\Memory\MemoryObject, implements Jamm\Memory\Shm\ISingleMemory
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$mem
$sem Jamm\Memory\Shm\IMutex

Открытые методы

Метод Описание
add ( string $key, mixed $value, integer $ttl = 2592000, string | array $tags = NULL ) : boolean | integer Add key to memory. If this key already exists - false will returned.
del ( string $key ) : boolean Delete key from memory
del_by_tags ( array | string $tags ) : boolean Delete keys by tags
del_old ( ) : boolean Delete old (by ttl) variables from storage
getSingleMemory ( )
get_keys ( ) Return array of all stored keys
increment ( string $key, mixed $by_value = 1, integer $limit_keys_count, integer $ttl = 259200 ) : integer | string | array Increment value of key
lock_key ( mixed $key, mixed &$auto_unlocker_variable ) 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, &$ttl_left ) : mixed Read key value from memory
save ( string $key, mixed $value, integer $ttl = 2592000, string | array $tags = NULL ) : boolean | void
select_fx ( callable $fx, boolean $get_array = false ) : mixed Select from memory elements by function $fx
setMutex ( Jamm\Memory\Shm\IMutex $mutex )
unlock_key ( KeyAutoUnlocker $key_auto_unlocker ) : boolean Unlock key, locked by method 'lock_key'

Защищенные методы

Метод Описание
get_key_ttl ( $key, &$mem )
readmemory ( )
refresh ( )

Описание методов

add() публичный Метод

Excludes simultaneously adding keys to exclude race condition.
public add ( string $key, mixed $value, integer $ttl = 2592000, string | array $tags = NULL ) : boolean | integer
$key string
$value mixed
$ttl integer
$tags string | array
Результат boolean | integer

del() публичный Метод

Delete key from memory
public del ( string $key ) : boolean
$key string
Результат boolean

del_by_tags() публичный Метод

Delete keys by tags
public del_by_tags ( array | string $tags ) : boolean
$tags array | string - tag or array of tags
Результат boolean

del_old() публичный Метод

Delete old (by ttl) variables from storage
public del_old ( ) : boolean
Результат boolean

getSingleMemory() публичный Метод

public getSingleMemory ( )

get_key_ttl() защищенный Метод

protected get_key_ttl ( $key, &$mem )

get_keys() публичный Метод

Return array of all stored keys
public get_keys ( )

increment() публичный Метод

Increment value of key
public increment ( string $key, mixed $by_value = 1, integer $limit_keys_count, integer $ttl = 259200 ) : integer | string | array
$key string
$by_value mixed if stored value is array: if $by_value is value in array, new element will be pushed to the end of array, if $by_value is key=>value array, key=>value pair will be added (or updated)
$limit_keys_count integer - maximum count of elements (used only if stored value is array)
$ttl integer
Результат integer | string | array new value of key

lock_key() публичный Метод

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 lock_key ( mixed $key, mixed &$auto_unlocker_variable )
$key mixed
$auto_unlocker_variable mixed - pass empty, just declared variable

read() публичный Метод

Read key value from memory
public read ( string | array $key, &$ttl_left ) : mixed
$key string | array
$ttl_left
Результат mixed

readmemory() абстрактный защищенный Метод

abstract protected readmemory ( )

refresh() абстрактный защищенный Метод

abstract protected refresh ( )

save() публичный Метод

public save ( string $key, mixed $value, integer $ttl = 2592000, string | array $tags = NULL ) : boolean | void
$key string key
$value mixed value
$ttl integer time to live
$tags string | array
Результат boolean | void

select_fx() публичный Метод

Select from memory elements by function $fx
public select_fx ( callable $fx, boolean $get_array = false ) : mixed
$fx callable
$get_array boolean
Результат mixed

setMutex() публичный Метод

public setMutex ( Jamm\Memory\Shm\IMutex $mutex )
$mutex Jamm\Memory\Shm\IMutex

unlock_key() публичный Метод

Unlock key, locked by method 'lock_key'
public unlock_key ( KeyAutoUnlocker $key_auto_unlocker ) : boolean
$key_auto_unlocker Jamm\Memory\KeyAutoUnlocker
Результат boolean

Описание свойств

$mem защищенное свойство

protected $mem

$sem защищенное свойство

protected IMutex,Jamm\Memory\Shm $sem
Результат Jamm\Memory\Shm\IMutex