PHP Class 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.
Author: Matthias Mullie ([email protected])
Inheritance: implements MatthiasMullie\Scrapbook\KeyValueStore
Afficher le fichier Open project: matthiasmullie/scrapbook

Protected Properties

Свойство Type Description
$items array
$limit integer
$size integer

Méthodes publiques

Méthode Description
__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 )

Méthodes protégées

Méthode Description
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.

Method Details

__construct() public méthode

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

add() public méthode

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

cas() public méthode

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

decrement() public méthode

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

delete() public méthode

public delete ( $key )

deleteMulti() public méthode

public deleteMulti ( array $keys )
$keys array

doIncrement() protected méthode

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
Résultat integer | boolean

evict() protected méthode

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

exists() protected méthode

Checks if a value exists in cache and is not yet expired.
protected exists ( string $key ) : boolean
$key string
Résultat boolean

flush() public méthode

public flush ( )

get() public méthode

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

getMulti() public méthode

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

increment() public méthode

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

lru() protected méthode

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() protected méthode

The first case (relative time) will be normalized into a fixed absolute timestamp.
protected normalizeTime ( integer $time ) : integer
$time integer
Résultat integer

replace() public méthode

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

set() public méthode

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

setMulti() public méthode

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

shorthandToBytes() protected méthode

Understands shorthand byte values (as used in e.g. memory_limit ini setting) and converts them into bytes.
See also: 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)
Résultat integer

touch() public méthode

public touch ( $key, $expire )

Property Details

$items protected_oe property

protected array $items
Résultat array

$limit protected_oe property

protected int $limit
Résultat integer

$size protected_oe property

protected int $size
Résultat integer