PHP Класс Jamm\Memory\APCObject

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

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

Свойство Тип Описание
$defragmentation_prefix
$lock_key_prefix because I love my wife Katya :)
$prefix
$tags_prefix

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

Метод Описание
__construct ( string $ID = '' )
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 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 It's very important function to prevent APC's cache fragmentation.
getKeyTTL ( string $key ) : integer Returns, how many seconds left till key expiring.
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 the 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
set_ID ( $ID )
set_tags ( string $key, string | array $tags, integer $ttl = self::max_ttl ) : boolean Associate tags with keys
unlock_key ( KeyAutoUnlocker $auto_unlocker ) : boolean Unlock key, locked by method 'lock_key'

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

Метод Описание
del_old_cached ( )

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

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

public __construct ( string $ID = '' )
$ID string

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
$key string | array
Результат 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 It's very important function to prevent APC's cache fragmentation.
public del_old ( ) : boolean
Результат boolean

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

protected del_old_cached ( )

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

Returns, how many seconds left till key expiring.
public getKeyTTL ( string $key ) : integer
$key string
Результат integer

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 the 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 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)
$limit_keys_count integer - maximum count of elements (used only if stored value is array)
$ttl integer - set time to live for key
Результат integer | string | array new value of key

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

Example: Process 1 reads key simultaneously with Process 2. Value of this key are too old, so Process 1 going to refresh it. Simultaneously with Process 2. But both of them trying to lock_key, and Process 1 only will refresh value of key (taking it from database, e.g.), and Process 2 can decide, what he want to do - use old value and not spent time to database, or something else.
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

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

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

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

Select from storage via callback function
public select_fx ( callable $fx, boolean $get_array = false ) : mixed
$fx callable ($value_array,$key)
$get_array boolean
Результат mixed

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

public set_ID ( $ID )

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

Associate tags with keys
public set_tags ( string $key, string | array $tags, integer $ttl = self::max_ttl ) : boolean
$key string
$tags string | array
$ttl integer
Результат boolean

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

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

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

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

protected $defragmentation_prefix

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

because I love my wife Katya :)
protected $lock_key_prefix

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

protected $prefix

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

protected $tags_prefix