Overview

Namespaces

  • Webmozart
    • KeyValueStore
      • Api
      • Decorator
      • Util

Classes

  • AbstractDecorator
  • CachingDecorator
  • CountableDecorator
  • SortableDecorator
  • Overview
  • Namespace
  • Class

Class CachingDecorator

A caching decorator implementing a cache layer for any store.

Webmozart\KeyValueStore\Decorator\AbstractDecorator implements Webmozart\KeyValueStore\Api\KeyValueStore
Extended by Webmozart\KeyValueStore\Decorator\CachingDecorator
Namespace: Webmozart\KeyValueStore\Decorator
Since: 1.0
Author: Bernhard Schussek bschussek@gmail.com
Located at Decorator/CachingDecorator.php
Methods summary
public
# __construct( Webmozart\KeyValueStore\Api\KeyValueStore $store, Doctrine\Common\Cache\Cache $cache, integer $ttl = 0 )

Creates the store.

Creates the store.

Parameters

$store
The cached store.
$cache
The cache.
$ttl

The time-to-live for cache entries. If set to 0, cache entries never expire.

Throws

InvalidArgumentException
If the provided cache is not supported

Overrides

Webmozart\KeyValueStore\Decorator\AbstractDecorator::__construct()
public
# set( integer|string $key, mixed $value )

Sets the value for a key in the store.

Sets the value for a key in the store.

Parameters

$key
The key to set.
$value
The value to set for the key.

Throws

WriteException
If the store cannot be written.
InvalidKeyException
If the key is not a string or integer.
SerializationFailedException
If the value cannot be serialized.
UnsupportedValueException

If the value is not supported by the implementation.

Overrides

Webmozart\KeyValueStore\Decorator\AbstractDecorator::set()
public mixed
# get( integer|string $key, mixed $default = null )

Returns the value of a key in the store.

Returns the value of a key in the store.

Parameters

$key
The key to get.
$default

The default value to return if the key does not exist.

Returns

mixed

The value of the key or the default value if the key does not exist.

Throws

ReadException
If the store cannot be read.
InvalidKeyException
If the key is not a string or integer.
UnserializationFailedException

If the stored value cannot be unserialized.

Overrides

Webmozart\KeyValueStore\Decorator\AbstractDecorator::get()
public mixed
# getOrFail( integer|string $key )

Returns the value of a key in the store.

Returns the value of a key in the store.

Parameters

$key
The key to get.

Returns

mixed
The value of the key.

Throws

ReadException
If the store cannot be read.
Webmozart\KeyValueStore\Api\NoSuchKeyException
If the key was not found.
InvalidKeyException
If the key is not a string or integer.
UnserializationFailedException

If the stored value cannot be unserialized.

Overrides

Webmozart\KeyValueStore\Decorator\AbstractDecorator::getOrFail()
public array
# getMultiple( array $keys, mixed $default = null )

Returns the values of multiple keys in the store.

Returns the values of multiple keys in the store.

Parameters

$keys
The keys to get. The keys must be strings or integers.
$default

The default value to return for keys that are not found.

Returns

array
The values of the passed keys, indexed by the keys.

Throws

ReadException
If the store cannot be read.
InvalidKeyException
If a key is not a string or integer.
UnserializationFailedException

If a stored value cannot be unserialized.

Overrides

Webmozart\KeyValueStore\Decorator\AbstractDecorator::getMultiple()
public array
# getMultipleOrFail( array $keys )

Returns the values of multiple keys in the store.

Returns the values of multiple keys in the store.

Parameters

$keys
The keys to get. The keys must be strings or integers.

Returns

array
The values of the passed keys, indexed by the keys.

Throws

ReadException
If the store cannot be read.
Webmozart\KeyValueStore\Api\NoSuchKeyException
If a key was not found.
InvalidKeyException
If a key is not a string or integer.
UnserializationFailedException

If a stored value cannot be unserialized.

Overrides

Webmozart\KeyValueStore\Decorator\AbstractDecorator::getMultipleOrFail()
public boolean
# remove( integer|string $key )

Removes a key from the store.

Removes a key from the store.

Parameters

$key
The key to remove.

Returns

boolean
Returns true if a key was removed from the store.

Throws

WriteException
If the store cannot be written.
InvalidKeyException
If the key is not a string or integer.

Overrides

Webmozart\KeyValueStore\Decorator\AbstractDecorator::remove()
public boolean
# exists( integer|string $key )

Returns whether a key exists.

Returns whether a key exists.

Parameters

$key
The key to test.

Returns

boolean
Whether the key exists in the store.

Throws

ReadException
If the store cannot be read.
InvalidKeyException
If the key is not a string or integer.

Overrides

Webmozart\KeyValueStore\Decorator\AbstractDecorator::exists()
public
# clear( )

Removes all keys from the store.

Removes all keys from the store.

Throws

WriteException
If the store cannot be written.

Overrides

Webmozart\KeyValueStore\Decorator\AbstractDecorator::clear()
Methods inherited from Webmozart\KeyValueStore\Decorator\AbstractDecorator
keys()
Properties inherited from Webmozart\KeyValueStore\Decorator\AbstractDecorator
$store
Webmozart Key-Value Store API API documentation generated by ApiGen