PHP 인터페이스 MatthiasMullie\Scrapbook\KeyValueStore

저자: Matthias Mullie ([email protected])
파일 보기 프로젝트 열기: matthiasmullie/scrapbook 0 사용 예제들

공개 메소드들

메소드 설명
add ( string $key, mixed $value, integer $expire ) : boolean Adds an item under new key.
cas ( mixed $token, string $key, mixed $value, integer $expire ) : boolean Replaces an item in 1 atomic operation, to ensure it didn't change since it was originally read, when the CAS token was issued.
decrement ( string $key, integer $offset = 1, integer $initial, integer $expire ) : integer | boolean Decrements a counter value, or sets an initial value if it does not yet exist.
delete ( string $key ) : boolean Deletes an item from the cache.
deleteMulti ( array $keys ) : bool[] Deletes multiple items at once (reduced network traffic compared to individual operations).
flush ( ) : boolean Clears the entire cache.
get ( string $key, mixed &$token = null ) : mixed | boolean Retrieves an item from the cache.
getMulti ( array $keys, array &$tokens = null ) : mixed[] Retrieves multiple items at once.
increment ( string $key, integer $offset = 1, integer $initial, integer $expire ) : integer | boolean Increments a counter value, or sets an initial value if it does not yet exist.
replace ( string $key, mixed $value, integer $expire ) : boolean Replaces an item.
set ( string $key, mixed $value, integer $expire ) : boolean Stores a value, regardless of whether or not the key already exists (in which case it will overwrite the existing value for that key).
setMulti ( array $items, integer $expire ) : bool[] Store multiple values at once.
touch ( string $key, integer $expire ) : boolean Updates an item's expiration time without altering the stored value.

메소드 상세

add() 공개 메소드

This operation fails (returns false) if the key already exists in cache. If the operation succeeds, true will be returned.
public add ( string $key, mixed $value, integer $expire ) : boolean
$key string
$value mixed
$expire integer Time when item falls out of the cache: 0 = permanent (doesn't expires); under 2592000 (30 days) = relative time, in seconds from now; over 2592000 = absolute time, unix timestamp
리턴 boolean

cas() 공개 메소드

This operation fails (returns false) if the CAS token didn't match with what's currently in cache, when a new value has been written to cache after we've fetched it. If the operation succeeds, true will be returned.
public cas ( mixed $token, string $key, mixed $value, integer $expire ) : boolean
$token mixed Token received from get() or getMulti()
$key string
$value mixed
$expire integer Time when item falls out of the cache: 0 = permanent (doesn't expires); under 2592000 (30 days) = relative time, in seconds from now; over 2592000 = absolute time, unix timestamp
리턴 boolean

decrement() 공개 메소드

The new counter value will be returned if this operation succeeds, or false for failure (e.g. when the value currently in cache is not a number, in which case it can't be decremented)
public decrement ( string $key, integer $offset = 1, integer $initial, integer $expire ) : integer | boolean
$key string
$offset integer Value to decrement with
$initial integer Initial value (if item doesn't yet exist)
$expire integer Time when item falls out of the cache: 0 = permanent (doesn't expires); under 2592000 (30 days) = relative time, in seconds from now; over 2592000 = absolute time, unix timestamp
리턴 integer | boolean New value or false on failure

delete() 공개 메소드

Returns true if item existed & was successfully deleted, false otherwise. Return value is a boolean true when the operation succeeds, or false on failure.
public delete ( string $key ) : boolean
$key string
리턴 boolean

deleteMulti() 공개 메소드

Return value will be an associative array in [key => status] form, where status is a boolean true for success, or false for failure.
public deleteMulti ( array $keys ) : bool[]
$keys array
리턴 bool[]

flush() 공개 메소드

Return value is a boolean true when the operation succeeds, or false on failure.
public flush ( ) : boolean
리턴 boolean

get() 공개 메소드

Optionally, an 2nd variable can be passed to this function. It will be filled with a value that can be used for cas()
public get ( string $key, mixed &$token = null ) : mixed | boolean
$key string
$token mixed Will be filled with the CAS token
리턴 mixed | boolean Value, or false on failure

getMulti() 공개 메소드

Return value will be an associative array in [key => value] format. Keys missing in cache will be omitted from the array. Optionally, an 2nd variable can be passed to this function. It will be filled with values that can be used for cas(), in an associative array in [key => token] format. Keys missing in cache will be omitted from the array. getMulti is preferred over multiple individual get operations as you'll get them all in 1 request.
public getMulti ( array $keys, array &$tokens = null ) : mixed[]
$keys array
$tokens array Will be filled with the CAS tokens, in [key => token] format
리턴 mixed[] [key => value]

increment() 공개 메소드

The new counter value will be returned if this operation succeeds, or false for failure (e.g. when the value currently in cache is not a number, in which case it can't be incremented)
public increment ( string $key, integer $offset = 1, integer $initial, integer $expire ) : integer | boolean
$key string
$offset integer Value to increment with
$initial integer Initial value (if item doesn't yet exist)
$expire integer Time when item falls out of the cache: 0 = permanent (doesn't expires); under 2592000 (30 days) = relative time, in seconds from now; over 2592000 = absolute time, unix timestamp
리턴 integer | boolean New value or false on failure

replace() 공개 메소드

This operation fails (returns false) if the key does not yet exist in cache. If the operation succeeds, true will be returned.
public replace ( string $key, mixed $value, integer $expire ) : boolean
$key string
$value mixed
$expire integer Time when item falls out of the cache: 0 = permanent (doesn't expires); under 2592000 (30 days) = relative time, in seconds from now; over 2592000 = absolute time, unix timestamp
리턴 boolean

set() 공개 메소드

Return value is a boolean true when the operation succeeds, or false on failure.
public set ( string $key, mixed $value, integer $expire ) : boolean
$key string
$value mixed
$expire integer Time when item falls out of the cache: 0 = permanent (doesn't expires); under 2592000 (30 days) = relative time, in seconds from now; over 2592000 = absolute time, unix timestamp
리턴 boolean

setMulti() 공개 메소드

Return value will be an associative array in [key => status] form, where status is a boolean true for success, or false for failure. setMulti is preferred over multiple individual set operations as you'll set them all in 1 request.
public setMulti ( array $items, integer $expire ) : bool[]
$items array [key => value]
$expire integer Time when item falls out of the cache: 0 = permanent (doesn't expires); under 2592000 (30 days) = relative time, in seconds from now; over 2592000 = absolute time, unix timestamp
리턴 bool[]

touch() 공개 메소드

Return value is a boolean true when the operation succeeds, or false on failure.
public touch ( string $key, integer $expire ) : boolean
$key string
$expire integer Time when item falls out of the cache: 0 = permanent (doesn't expires); under 2592000 (30 days) = relative time, in seconds from now; over 2592000 = absolute time, unix timestamp
리턴 boolean