PHP 인터페이스 Webmozart\KeyValueStore\Api\KeyValueStore

KeyUtil-value stores support storing values for integer or string keys chosen by the user. Any serializable value can be stored, although an implementation of this interface may further restrict the range of accepted values. See the documentation of the implementation for more information.
부터: 1.0
저자: Bernhard Schussek ([email protected])
파일 보기 프로젝트 열기: webmozart/key-value-store 0 사용 예제들

공개 메소드들

메소드 설명
clear ( ) Removes all keys from the store.
exists ( integer | string $key ) : boolean Returns whether a key exists.
get ( integer | string $key, mixed $default = null ) : mixed Returns the value of a key in the store.
getMultiple ( array $keys, mixed $default = null ) : array Returns the values of multiple keys in the store.
getMultipleOrFail ( array $keys ) : array Returns the values of multiple keys in the store.
getOrFail ( integer | string $key ) : mixed Returns the value of a key in the store.
keys ( ) : array Returns all keys currently stored in the store.
remove ( integer | string $key ) : boolean Removes a key from the store.
set ( integer | string $key, mixed $value ) Sets the value for a key in the store.

메소드 상세

clear() 공개 메소드

If the backend of the store cannot be written, a {@link WriteException} is thrown. You should always handle this exception in your code: php try { $store->clear(); } catch (WriteException $e) { write failed }
public clear ( )

exists() 공개 메소드

Any integer or string value is accepted as key. If any other type is passed for the key, an {@link InvalidKeyException} is thrown. You should make sure that you only pass valid keys to the store. If the backend of the store cannot be read, a {@link ReadException} is thrown. You should always handle this exception in your code: php try { if ($store->exists($key)) { ... } } catch (ReadException $e) { read failed }
public exists ( integer | string $key ) : boolean
$key integer | string The key to test.
리턴 boolean Whether the key exists in the store.

get() 공개 메소드

If a key does not exist in the store, the default value passed in the second parameter is returned. Any integer or string value is accepted as key. If any other type is passed for the key, an {@link InvalidKeyException} is thrown. You should make sure that you only pass valid keys to the store. If the backend of the store cannot be read, a {@link ReadException} is thrown. You should always handle this exception in your code: php try { $value = $store->get($key); } catch (ReadException $e) { read failed }
public get ( integer | string $key, mixed $default = null ) : mixed
$key integer | string The key to get.
$default mixed The default value to return if the key does not exist.
리턴 mixed The value of the key or the default value if the key does not exist.

getMultiple() 공개 메소드

The passed default value is returned for keys that don't exist. Any integer or string value is accepted as key. If any other type is passed for the key, an {@link InvalidKeyException} is thrown. You should make sure that you only pass valid keys to the store. If the backend of the store cannot be read, a {@link ReadException} is thrown. You should always handle this exception in your code: php try { $value = $store->getMultiple(array($key1, $key2)); } catch (ReadException $e) { read failed }
public getMultiple ( array $keys, mixed $default = null ) : array
$keys array The keys to get. The keys must be strings or integers.
$default mixed The default value to return for keys that are not found.
리턴 array The values of the passed keys, indexed by the keys.

getMultipleOrFail() 공개 메소드

If a key does not exist in the store, an exception is thrown. Any integer or string value is accepted as key. If any other type is passed for the key, an {@link InvalidKeyException} is thrown. You should make sure that you only pass valid keys to the store. If the backend of the store cannot be read, a {@link ReadException} is thrown. You should always handle this exception in your code: php try { $value = $store->getMultipleOrFail(array($key1, $key2)); } catch (ReadException $e) { read failed }
public getMultipleOrFail ( array $keys ) : array
$keys array The keys to get. The keys must be strings or integers.
리턴 array The values of the passed keys, indexed by the keys.

getOrFail() 공개 메소드

If the key does not exist in the store, an exception is thrown. Any integer or string value is accepted as key. If any other type is passed for the key, an {@link InvalidKeyException} is thrown. You should make sure that you only pass valid keys to the store. If the backend of the store cannot be read, a {@link ReadException} is thrown. You should always handle this exception in your code: php try { $value = $store->getOrFail($key); } catch (ReadException $e) { read failed }
public getOrFail ( integer | string $key ) : mixed
$key integer | string The key to get.
리턴 mixed The value of the key.

keys() 공개 메소드

If the backend of the store cannot be read, a {@link ReadException} is thrown. You should always handle this exception in your code: php try { foreach ($store->keys() as $key) { ... } } catch (ReadException $e) { read failed }
public keys ( ) : array
리턴 array The keys stored in the store. Each key is either a string or an integer. The order of the keys is undefined.

remove() 공개 메소드

If the store does not contain the key, this method returns false. Any integer or string value is accepted as key. If any other type is passed for the key, an {@link InvalidKeyException} is thrown. You should make sure that you only pass valid keys to the store. If the backend of the store cannot be written, a {@link WriteException} is thrown. You should always handle this exception in your code: php try { $store->remove($key); } catch (WriteException $e) { write failed }
public remove ( integer | string $key ) : boolean
$key integer | string The key to remove.
리턴 boolean Returns `true` if a key was removed from the store.

set() 공개 메소드

The key-value store accepts any serializable value. If a value is not serializable, a {@link SerializationFailedException} is thrown. Additionally, implementations may put further restrictions on their accepted values. If an unsupported value is passed, an {@link UnsupportedValueException} is thrown. Check the documentation of the implementation to learn more about its supported values. Any integer or string value is accepted as key. If any other type is passed for the key, an {@link InvalidKeyException} is thrown. You should make sure that you only pass valid keys to the store. If the backend of the store cannot be written, a {@link WriteException} is thrown. You should always handle this exception in your code: php try { $store->set($key, $value); } catch (WriteException $e) { write failed }
public set ( integer | string $key, mixed $value )
$key integer | string The key to set.
$value mixed The value to set for the key.