PHP Class MatthiasMullie\Scrapbook\Buffered\TransactionalStore

This makes it possible to defer cache updates until we can guarantee it's safe (e.g. until we successfully committed everything to persistent storage). There will be some trickery to make sure that, after we've made changes to cache (but not yet committed), we don't read from the real cache anymore, but instead serve the in-memory equivalent that we'll be writing to real cache when all goes well. If a commit fails, all keys affected will be deleted to ensure no corrupt data stays behind.
Author: Matthias Mullie ([email protected])
Inheritance: implements MatthiasMullie\Scrapbook\KeyValueStore
Mostrar archivo Open project: matthiasmullie/scrapbook

Protected Properties

Property Type Description
$transactions MatthiasMullie\Scrapbook\KeyValueStore[] Array of KeyValueStore objects. Every cache action will be executed on the last item in this array, so transactions can be nested.

Public Methods

Method Description
__construct ( MatthiasMullie\Scrapbook\KeyValueStore $cache )
__destruct ( ) Roll back uncommitted transactions.
add ( $key, $value, $expire )
begin ( ) Initiate a transaction: this will defer all writes to real cache until commit() is called.
cas ( $token, $key, $value, $expire )
commit ( ) : boolean Commits all deferred updates to real cache.
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 )
rollback ( ) : boolean Roll back all scheduled changes.
set ( $key, $value, $expire )
setMulti ( array $items, $expire )
touch ( $key, $expire )

Method Details

__construct() public method

public __construct ( MatthiasMullie\Scrapbook\KeyValueStore $cache )
$cache MatthiasMullie\Scrapbook\KeyValueStore The real cache we'll buffer for

__destruct() public method

Roll back uncommitted transactions.
public __destruct ( )

add() public method

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

begin() public method

Initiate a transaction: this will defer all writes to real cache until commit() is called.
public begin ( )

cas() public method

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

commit() public method

If the any write fails, all subsequent writes will be aborted & all keys that had already been written to will be deleted.
public commit ( ) : boolean
return boolean

decrement() public method

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

delete() public method

public delete ( $key )

deleteMulti() public method

public deleteMulti ( array $keys )
$keys array

flush() public method

public flush ( )

get() public method

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

getMulti() public method

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

increment() public method

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

replace() public method

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

rollback() public method

Roll back all scheduled changes.
public rollback ( ) : boolean
return boolean

set() public method

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

setMulti() public method

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

touch() public method

public touch ( $key, $expire )

Property Details

$transactions protected_oe property

Array of KeyValueStore objects. Every cache action will be executed on the last item in this array, so transactions can be nested.
protected KeyValueStore[],MatthiasMullie\Scrapbook $transactions
return MatthiasMullie\Scrapbook\KeyValueStore[]