PHP Class MatthiasMullie\Scrapbook\Scale\Shard

Pass the individual KeyValueStore objects that compose the cache server pool into this constructor how you want the data to be sharded. The cache data will be sharded over them according to the order they were in when they were passed into this constructor (so make sure to always keep the order the same) The sharding is spread evenly and all cache servers will roughly receive the same amount of cache keys. If some servers are bigger than others, you can offset this by adding the KeyValueStore object more than once. Data can even be sharded among different adapters: one server in the shard pool can be Redis while another can be Memcached. Not sure why you would even want that, but you could!
Author: Matthias Mullie ([email protected])
Inheritance: implements MatthiasMullie\Scrapbook\KeyValueStore
Afficher le fichier Open project: matthiasmullie/scrapbook

Protected Properties

Свойство Type Description
$caches MatthiasMullie\Scrapbook\KeyValueStore[]

Méthodes publiques

Méthode Description
__construct ( MatthiasMullie\Scrapbook\KeyValueStore $cache1, MatthiasMullie\Scrapbook\KeyValueStore $cache2 = null ) Overloadable with multiple KeyValueStore objects.
add ( $key, $value, $expire )
addCache ( MatthiasMullie\Scrapbook\KeyValueStore $cache )
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
getShard ( string $key ) : MatthiasMullie\Scrapbook\KeyValueStore Get the shard (KeyValueStore object) that corresponds to a particular cache key.
getShards ( array $keys ) : SplObjectStorage Get a [KeyValueStore => array of cache keys] map (SplObjectStorage) for multiple cache keys.

Method Details

__construct() public méthode

Overloadable with multiple KeyValueStore objects.
public __construct ( MatthiasMullie\Scrapbook\KeyValueStore $cache1, MatthiasMullie\Scrapbook\KeyValueStore $cache2 = null )
$cache1 MatthiasMullie\Scrapbook\KeyValueStore
$cache2 MatthiasMullie\Scrapbook\KeyValueStore

add() public méthode

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

addCache() public méthode

public addCache ( MatthiasMullie\Scrapbook\KeyValueStore $cache )
$cache MatthiasMullie\Scrapbook\KeyValueStore

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

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

getShard() protected méthode

Get the shard (KeyValueStore object) that corresponds to a particular cache key.
protected getShard ( string $key ) : MatthiasMullie\Scrapbook\KeyValueStore
$key string
Résultat MatthiasMullie\Scrapbook\KeyValueStore

getShards() protected méthode

Get a [KeyValueStore => array of cache keys] map (SplObjectStorage) for multiple cache keys.
protected getShards ( array $keys ) : SplObjectStorage
$keys array
Résultat SplObjectStorage

increment() public méthode

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

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

touch() public méthode

public touch ( $key, $expire )

Property Details

$caches protected_oe property

protected KeyValueStore[],MatthiasMullie\Scrapbook $caches
Résultat MatthiasMullie\Scrapbook\KeyValueStore[]