PHP Класс Jamm\Memory\MemcacheObject

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

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

Свойство Тип Описание
$lock_key_prefix string
$memcache Jamm\Memory\IMemcacheDecorator
$prefix
$tag_prefix
$ttl_table_name string array (key=>ttl)

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

Метод Описание
__construct ( string $ID = '', string $host = 'localhost', integer $port = 11211 )
add ( string $key, mixed $value, integer $ttl = 259200, array | string $tags = NULL ) : boolean Add value to memory storage, only if this key does not exists (or false will be returned).
del ( string | array $key ) : boolean | array Delete key or array of keys from storage
del_by_tags ( array | string $tags ) : boolean Delete keys by tags
del_old ( ) : boolean Delete old (by ttl) variables from storage
getKeyTTL ( $key )
get_ID ( )
get_keys ( ) Return array of all stored keys
get_stat ( ) : array
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 ) : 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 &$ttl_left ) : mixed Read data from memory storage
save ( string $key, mixed $value, integer $ttl = 259200, array | string $tags = NULL ) : boolean Save variable in memory storage
select_fx ( callable $fx, boolean $get_array = false ) : mixed Select from storage via callback function Only values of 'array' type will be selected
set_ID ( $ID )
unlock_key ( KeyAutoUnlocker $auto_unlocker ) : boolean Unlock key, locked by method 'lock_key'

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

Метод Описание
delTTLOfKey ( $key, &$ttl_table )
getKeysOfTag ( $tag )
read_TTL_table ( )
save_TTL_table ( array $table ) : void
setKeyTTL ( $key, $ttl )
setMemcacheObject ( $host = 'localhost', $port = 11211 )
setTags ( string $key, array | string $tags ) : boolean
ttl_to_expiration ( $ttl )

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

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

public __construct ( string $ID = '', string $host = 'localhost', integer $port = 11211 )
$ID string Symbol "." will be replaced to "_"
$host string
$port integer

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

Add value to memory storage, only if this key does not exists (or false will be returned).
public add ( string $key, mixed $value, integer $ttl = 259200, array | string $tags = NULL ) : boolean
$key string
$value mixed
$ttl integer
$tags array | string
Результат boolean

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

Delete key or array of keys from storage
public del ( string | array $key ) : boolean | array
$key string | array - keys
Результат boolean | array - if array of keys was passed, on error will be returned array of not deleted keys, or 'true' on success.

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

protected delTTLOfKey ( $key, &$ttl_table )

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

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

public getKeyTTL ( $key )

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

protected getKeysOfTag ( $tag )

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

public get_ID ( )

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

Return array of all stored keys
public get_keys ( )

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

public get_stat ( ) : array
Результат array

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 ) : boolean
$key mixed
$auto_unlocker_variable mixed - pass empty, just declared variable
Результат boolean

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

Read data from memory storage
public read ( string | array $key, mixed &$ttl_left ) : mixed
$key string | array (string or array of string keys)
$ttl_left mixed = (ttl - time()) of key. Use to exclude dog-pile effect, with lock/unlock_key methods.
Результат mixed

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

protected read_TTL_table ( )

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

Save variable in memory storage
public save ( string $key, mixed $value, integer $ttl = 259200, array | string $tags = NULL ) : boolean
$key string - key
$value mixed - value
$ttl integer - time to live (store) in seconds
$tags array | string - array of tags for this key
Результат boolean

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

protected save_TTL_table ( array $table ) : void
$table array
Результат void

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

Select from storage via callback function Only values of 'array' type will be selected
public select_fx ( callable $fx, boolean $get_array = false ) : mixed
$fx callable ($value_array,$key)
$get_array boolean
Результат mixed

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

protected setKeyTTL ( $key, $ttl )

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

protected setMemcacheObject ( $host = 'localhost', $port = 11211 )

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

protected setTags ( string $key, array | string $tags ) : boolean
$key string
$tags array | string
Результат boolean

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

public set_ID ( $ID )

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

protected ttl_to_expiration ( $ttl )

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

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

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

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

protected string $lock_key_prefix
Результат string

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

protected IMemcacheDecorator,Jamm\Memory $memcache
Результат Jamm\Memory\IMemcacheDecorator

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

protected $prefix

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

protected $tag_prefix

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

array (key=>ttl)
protected string $ttl_table_name
Результат string