PHP 클래스 MatthiasMullie\Scrapbook\Buffered\Utils\Transaction

This class accepts 2 caches: a KeyValueStore object (the real cache) and a Buffer instance (to read data from as long as it hasn't been committed) Every write action will first store the data in the Buffer instance, and then pas update along to $defer. Once commit() is called, $defer will execute all these updates against the real cache. All deferred writes that fail to apply will cause that cache key to be deleted, to ensure cache consistency. Until commit() is called, all data is read from the temporary Buffer instance.
저자: Matthias Mullie ([email protected])
상속: implements MatthiasMullie\Scrapbook\KeyValueStore
파일 보기 프로젝트 열기: matthiasmullie/scrapbook 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$cache MatthiasMullie\Scrapbook\KeyValueStore
$defer Defer Deferred updates to be committed to real cache.
$local Buffer
$suspend boolean Suspend reads from real cache. This is used when a flush is issued but it has not yet been committed. In that case, we don't want to fall back to real cache values, because they're about to be flushed.
$tokens mixed[] We'll return stub CAS tokens in order to reliably replay the CAS actions to the real cache. This will hold a map of stub token => value, used to verify when we do the actual CAS.

공개 메소드들

메소드 설명
__construct ( Buffer $local, MatthiasMullie\Scrapbook\KeyValueStore $cache )
add ( $key, $value, $expire )
cas ( $token, $key, $value, $expire ) Since our CAS is deferred, the CAS token we got from our original get() will likely not be valid by the time we want to store it to the real cache. Imagine this scenario: * a value is fetched from (real) cache * an new value key is CAS'ed (into temp cache - real CAS is deferred) * this key's value is fetched again (this time from temp cache) * and a new value is CAS'ed again (into temp cache.
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 )

보호된 메소드들

메소드 설명
clear ( ) Clears all transaction-related data stored in memory.

메소드 상세

__construct() 공개 메소드

public __construct ( Buffer $local, MatthiasMullie\Scrapbook\KeyValueStore $cache )
$local Buffer
$cache MatthiasMullie\Scrapbook\KeyValueStore

add() 공개 메소드

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

cas() 공개 메소드

..). In this scenario, when we finally want to replay the write actions onto the real cache, the first 3 actions would likely work fine. The last (second CAS) however would not, since it never got a real updated $token from the real cache. To work around this problem, all get() calls will return a unique CAS token and store the value-at-that-time associated with that token. All we have to do when we want to write the data to real cache is, right before was CAS for real, get the value & (real) cas token from storage & compare that value to the one we had stored. If that checks out, we can safely resume the CAS with the real token we just received. {@inheritdoc}
public cas ( $token, $key, $value, $expire )

clear() 보호된 메소드

Clears all transaction-related data stored in memory.
protected clear ( )

commit() 공개 메소드

that had already been written to will be deleted.
public commit ( ) : boolean
리턴 boolean

decrement() 공개 메소드

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

delete() 공개 메소드

public delete ( $key )

deleteMulti() 공개 메소드

public deleteMulti ( array $keys )
$keys array

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 )

replace() 공개 메소드

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

rollback() 공개 메소드

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

set() 공개 메소드

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

setMulti() 공개 메소드

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

touch() 공개 메소드

public touch ( $key, $expire )

프로퍼티 상세

$cache 보호되어 있는 프로퍼티

protected KeyValueStore,MatthiasMullie\Scrapbook $cache
리턴 MatthiasMullie\Scrapbook\KeyValueStore

$defer 보호되어 있는 프로퍼티

Deferred updates to be committed to real cache.
protected Defer,MatthiasMullie\Scrapbook\Buffered\Utils $defer
리턴 Defer

$local 보호되어 있는 프로퍼티

protected Buffer,MatthiasMullie\Scrapbook\Buffered\Utils $local
리턴 Buffer

$suspend 보호되어 있는 프로퍼티

Suspend reads from real cache. This is used when a flush is issued but it has not yet been committed. In that case, we don't want to fall back to real cache values, because they're about to be flushed.
protected bool $suspend
리턴 boolean

$tokens 보호되어 있는 프로퍼티

We'll return stub CAS tokens in order to reliably replay the CAS actions to the real cache. This will hold a map of stub token => value, used to verify when we do the actual CAS.
또한 보기: cas()
protected mixed[] $tokens
리턴 mixed[]