PHP Класс MatthiasMullie\Scrapbook\Adapters\Apc

Автор: Matthias Mullie ([email protected])
Наследование: implements MatthiasMullie\Scrapbook\KeyValueStore
Показать файл Открыть проект

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

Свойство Тип Описание
$expires array APC does this crazy thing of only deleting expired data on every new (page) request, not checking it when you actually retrieve the value (which you may just have set in the same request) Since it's totally possible to store values that expire in the same request, we'll keep track of those expiration times here & filter them out in case they did expire.

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

Метод Описание
__construct ( )
add ( $key, $value, $expire )
cas ( $token, $key, $value, $expire )
decrement ( $key, $offset = 1, $initial, $expire )
delete ( $key )
deleteMulti ( array $keys )
flush ( )
get ( $key, &$token = null )
getMulti ( array $keys, array &$tokens = null )
increment ( $key, $offset = 1, $initial, $expire )
replace ( $key, $value, $expire )
set ( $key, $value, $expire )
setMulti ( array $items, $expire )
touch ( $key, $expire )

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

Метод Описание
APCuIterator ( string | string[] | null $search = null, integer $format = null, integer $chunk_size = null, integer $list = null ) : APCIterato\APCIterator | APCuIterato\APCuIterator
acquire ( string | string[] $keys ) : string[] Acquire a lock - required to provide CAS functionality.
apcu_add ( string | string[] $key, mixed $var, integer $ttl ) : boolean | bool[]
apcu_clear_cache ( ) : boolean
apcu_delete ( string | string[] | APCIterato\APCIterator | APCuIterato\APCuIterator $key ) : boolean | string[]
apcu_fetch ( string | string[] $key, boolean &$success = null ) : mixed | false
apcu_store ( string | string[] $key, mixed $var, integer $ttl ) : boolean | bool[]
doIncrement ( string $key, integer $offset, integer $initial, integer $expire ) : integer | boolean Shared between increment/decrement: both have mostly the same logic (decrement just increments a negative value), but need their validation split up (increment won't accept negative values).
expire ( array | string $key = [], integer $ttl ) Store the expiration time for items we're setting in this request, to work around APC's behavior of only clearing expires per page request.
lock ( string | string[] $keys ) : array Acquire a lock. If we failed to acquire a lock, it'll automatically try again in 1ms, for a maximum of 10 times.
ttl ( integer $expire ) : integer APC expects true TTL, not expiration timestamp.
unlock ( string | string[] $keys ) : boolean Release a lock.

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

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

protected APCuIterator ( string | string[] | null $search = null, integer $format = null, integer $chunk_size = null, integer $list = null ) : APCIterato\APCIterator | APCuIterato\APCuIterator
$search string | string[] | null
$format integer
$chunk_size integer
$list integer
Результат APCIterato\APCIterator | APCuIterato\APCuIterator

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

public __construct ( )

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

Acquire a lock - required to provide CAS functionality.
protected acquire ( string | string[] $keys ) : string[]
$keys string | string[]
Результат string[] Array of successfully locked keys

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

public add ( $key, $value, $expire )

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

protected apcu_add ( string | string[] $key, mixed $var, integer $ttl ) : boolean | bool[]
$key string | string[]
$var mixed
$ttl integer
Результат boolean | bool[]

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

protected apcu_clear_cache ( ) : boolean
Результат boolean

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

protected apcu_delete ( string | string[] | APCIterato\APCIterator | APCuIterato\APCuIterator $key ) : boolean | string[]
$key string | string[] | APCIterato\APCIterator | APCuIterato\APCuIterator
Результат boolean | string[]

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

protected apcu_fetch ( string | string[] $key, boolean &$success = null ) : mixed | false
$key string | string[]
$success boolean
Результат mixed | false

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

protected apcu_store ( string | string[] $key, mixed $var, integer $ttl ) : boolean | bool[]
$key string | string[]
$var mixed
$ttl integer
Результат boolean | bool[]

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

public cas ( $token, $key, $value, $expire )

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

public decrement ( $key, $offset = 1, $initial, $expire )

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

public delete ( $key )

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

public deleteMulti ( array $keys )
$keys array

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

Shared between increment/decrement: both have mostly the same logic (decrement just increments a negative value), but need their validation split up (increment won't accept negative values).
protected doIncrement ( string $key, integer $offset, integer $initial, integer $expire ) : integer | boolean
$key string
$offset integer
$initial integer
$expire integer
Результат integer | boolean

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

Store the expiration time for items we're setting in this request, to work around APC's behavior of only clearing expires per page request.
См. также: static::$expires
protected expire ( array | string $key = [], integer $ttl )
$key array | string
$ttl integer

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

public flush ( )

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

public get ( $key, &$token = null )

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

public getMulti ( array $keys, array &$tokens = null )
$keys array
$tokens array

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

public increment ( $key, $offset = 1, $initial, $expire )

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

APC provides nothing that would allow us to do CAS. To "emulate" CAS, we'll work with locks: all cache writes also briefly create a lock cache entry (yup: #writes * 3, for lock & unlock - luckily, they're not over the network) Writes are disallows when a lock can't be obtained (= locked by another write), which makes it possible for us to first retrieve, compare & then set in a nob-atomic way. However, there's a possibility for interference with direct APC access touching the same keys - e.g. other scripts, not using this class. If CAS is of importance, make sure the only things touching APC on your server is using these classes!
protected lock ( string | string[] $keys ) : array
$keys string | string[]
Результат array Array of successfully locked keys

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

public replace ( $key, $value, $expire )

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

public set ( $key, $value, $expire )

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

public setMulti ( array $items, $expire )
$items array

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

public touch ( $key, $expire )

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

APC expects true TTL, not expiration timestamp.
protected ttl ( integer $expire ) : integer
$expire integer
Результат integer TTL in seconds

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

Release a lock.
protected unlock ( string | string[] $keys ) : boolean
$keys string | string[]
Результат boolean

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

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

APC does this crazy thing of only deleting expired data on every new (page) request, not checking it when you actually retrieve the value (which you may just have set in the same request) Since it's totally possible to store values that expire in the same request, we'll keep track of those expiration times here & filter them out in case they did expire.
См. также: http://stackoverflow.com/questions/11750223/apc-user-cache-entries-not-expiring
protected array $expires
Результат array