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

This is mainly useful for testing purposes, where this class can let you test application logic against cache, without having to run a cache server.
Автор: Matthias Mullie ([email protected])
Наследование: implements MatthiasMullie\Scrapbook\KeyValueStore
Показать файл Открыть проект

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

Свойство Тип Описание
$items array
$limit integer
$size integer

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

Метод Описание
__construct ( integer | string $limit = null )
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 )

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

Метод Описание
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).
evict ( ) Least recently used cache values will be evicted from cache should it fill up too much.
exists ( string $key ) : boolean Checks if a value exists in cache and is not yet expired.
lru ( $key ) This cache uses least recently used algorithm. This is to be called with the key to be marked as just used.
normalizeTime ( integer $time ) : integer Times can be: * relative (in seconds) to current time, within 30 days * absolute unix timestamp * 0, for infinity.
shorthandToBytes ( string | integer $shorthand ) : integer Understands shorthand byte values (as used in e.g. memory_limit ini setting) and converts them into bytes.

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

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

public __construct ( integer | string $limit = null )
$limit integer | string Memory limit in bytes (defaults to 10% of memory_limit)

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

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

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

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

Least recently used cache values will be evicted from cache should it fill up too much.
protected evict ( )

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

Checks if a value exists in cache and is not yet expired.
protected exists ( string $key ) : boolean
$key string
Результат boolean

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 )

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

This cache uses least recently used algorithm. This is to be called with the key to be marked as just used.
protected lru ( $key )

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

The first case (relative time) will be normalized into a fixed absolute timestamp.
protected normalizeTime ( integer $time ) : integer
$time integer
Результат integer

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

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

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

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

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

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

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

Understands shorthand byte values (as used in e.g. memory_limit ini setting) and converts them into bytes.
См. также: http://php.net/manual/en/faq.using.php#faq.using.shorthandbytes
protected shorthandToBytes ( string | integer $shorthand ) : integer
$shorthand string | integer Amount of bytes (int) or shorthand value (e.g. 512M)
Результат integer

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

public touch ( $key, $expire )

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

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

protected array $items
Результат array

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

protected int $limit
Результат integer

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

protected int $size
Результат integer