Zend Framework  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Redis Class Reference

Public Member Functions

 __construct ($options=null)
 Create new Adapter for redis storage.
 
 setOptions ($options)
 Set options.
 
 getOptions ()
 Get options.
 
 flush ()
 Flush currently set DB.
 
 clearByNamespace ($namespace)
 Remove items of given namespace.
 
 clearByPrefix ($prefix)
 Remove items matching given prefix.
 
 getTotalSpace ()
 Get total space in bytes.
 
- Public Member Functions inherited from AbstractAdapter
 __construct ($options=null)
 Constructor.
 
 __destruct ()
 Destructor.
 
 setOptions ($options)
 Set options.
 
 getOptions ()
 Get options.
 
 setCaching ($flag)
 Enable/Disable caching.
 
 getCaching ()
 Get caching enabled.
 
 getEventManager ()
 Get the event manager.
 
 hasPlugin (Plugin\PluginInterface $plugin)
 Check if a plugin is registered.
 
 addPlugin (Plugin\PluginInterface $plugin, $priority=1)
 Register a plugin.
 
 removePlugin (Plugin\PluginInterface $plugin)
 Unregister an already registered plugin.
 
 getPluginRegistry ()
 Return registry of plugins.
 
 getItem ($key, &$success=null, &$casToken=null)
 Get an item.
 
 getItems (array $keys)
 Get multiple items.
 
 hasItem ($key)
 Test if an item exists.
 
 hasItems (array $keys)
 Test multiple items.
 
 getMetadata ($key)
 Get metadata of an item.
 
 getMetadatas (array $keys)
 Get multiple metadata.
 
 setItem ($key, $value)
 Store an item.
 
 setItems (array $keyValuePairs)
 Store multiple items.
 
 addItem ($key, $value)
 Add an item.
 
 addItems (array $keyValuePairs)
 Add multiple items.
 
 replaceItem ($key, $value)
 Replace an existing item.
 
 replaceItems (array $keyValuePairs)
 Replace multiple existing items.
 
 checkAndSetItem ($token, $key, $value)
 Set an item only if token matches.
 
 touchItem ($key)
 Reset lifetime of an item.
 
 touchItems (array $keys)
 Reset lifetime of multiple items.
 
 removeItem ($key)
 Remove an item.
 
 removeItems (array $keys)
 Remove multiple items.
 
 incrementItem ($key, $value)
 Increment an item.
 
 incrementItems (array $keyValuePairs)
 Increment multiple items.
 
 decrementItem ($key, $value)
 Decrement an item.
 
 decrementItems (array $keyValuePairs)
 Decrement multiple items.
 
 getCapabilities ()
 Get capabilities of this adapter.
 

Protected Member Functions

 getRedisResource ()
 Get Redis resource.
 
 internalGetItem (&$normalizedKey, &$success=null, &$casToken=null)
 Internal method to get an item.
 
 internalGetItems (array &$normalizedKeys)
 Internal method to get multiple items.
 
 internalHasItem (&$normalizedKey)
 Internal method to test if an item exists.
 
 internalSetItem (&$normalizedKey, &$value)
 Internal method to store an item.
 
 internalSetItems (array &$normalizedKeyValuePairs)
 Internal method to store multiple items.
 
 internalAddItem (&$normalizedKey, &$value)
 Add an item.
 
 internalTouchItem (&$normalizedKey)
 Internal method to touch an item.
 
 internalRemoveItem (&$normalizedKey)
 Internal method to remove an item.
 
 internalIncrementItem (&$normalizedKey, &$value)
 Internal method to increment an item.
 
 internalDecrementItem (&$normalizedKey, &$value)
 Internal method to decrement an item.
 
 internalGetCapabilities ()
 Internal method to get capabilities of this adapter.
 
 internalGetMetadata (&$normalizedKey)
 
 
 preSerialize ($value)
 Pre-Serialize value before putting it to the redis extension The reason for this is the buggy extension version < 2.5.7 which is producing a segfault on storing NULL as long as no serializer was configured.
 
- Protected Member Functions inherited from AbstractAdapter
 triggerPre ($eventName, ArrayObject $args)
 Trigger a pre event and return the event response collection.
 
 triggerPost ($eventName, ArrayObject $args, &$result)
 Triggers the PostEvent and return the result value.
 
 triggerException ($eventName, ArrayObject $args, &$result,\Exception $exception)
 Trigger an exception event.
 
 internalGetItem (&$normalizedKey, &$success=null, &$casToken=null)
 Internal method to get an item.
 
 internalGetItems (array &$normalizedKeys)
 Internal method to get multiple items.
 
 internalHasItem (&$normalizedKey)
 Internal method to test if an item exists.
 
 internalHasItems (array &$normalizedKeys)
 Internal method to test multiple items.
 
 internalGetMetadata (&$normalizedKey)
 Internal method to get metadata of an item.
 
 internalGetMetadatas (array &$normalizedKeys)
 Internal method to get multiple metadata.
 
 internalSetItem (&$normalizedKey, &$value)
 Internal method to store an item.
 
 internalSetItems (array &$normalizedKeyValuePairs)
 Internal method to store multiple items.
 
 internalAddItem (&$normalizedKey, &$value)
 Internal method to add an item.
 
 internalAddItems (array &$normalizedKeyValuePairs)
 Internal method to add multiple items.
 
 internalReplaceItem (&$normalizedKey, &$value)
 Internal method to replace an existing item.
 
 internalReplaceItems (array &$normalizedKeyValuePairs)
 Internal method to replace multiple existing items.
 
 internalCheckAndSetItem (&$token, &$normalizedKey, &$value)
 Internal method to set an item only if token matches.
 
 internalTouchItem (&$normalizedKey)
 Internal method to reset lifetime of an item.
 
 internalTouchItems (array &$normalizedKeys)
 Internal method to reset lifetime of multiple items.
 
 internalRemoveItem (&$normalizedKey)
 Internal method to remove an item.
 
 internalRemoveItems (array &$normalizedKeys)
 Internal method to remove multiple items.
 
 internalIncrementItem (&$normalizedKey, &$value)
 Internal method to increment an item.
 
 internalIncrementItems (array &$normalizedKeyValuePairs)
 Internal method to increment multiple items.
 
 internalDecrementItem (&$normalizedKey, &$value)
 Internal method to decrement an item.
 
 internalDecrementItems (array &$normalizedKeyValuePairs)
 Internal method to decrement multiple items.
 
 internalGetCapabilities ()
 Internal method to get capabilities of this adapter.
 
 normalizeKey (&$key)
 Validates and normalizes a key.
 
 normalizeKeys (array &$keys)
 Validates and normalizes multiple keys.
 
 normalizeKeyValuePairs (array &$keyValuePairs)
 Validates and normalizes an array of key-value pairs.
 

Protected Attributes

 $initialized = false
 
 $resourceManager
 
 $resourceId
 
 $namespacePrefix = ''
 
- Protected Attributes inherited from AbstractAdapter
 $events = null
 
 $eventHandles = []
 
 $pluginRegistry
 
 $capabilities = null
 
 $capabilityMarker
 
 $options
 

Constructor & Destructor Documentation

__construct (   $options = null)

Create new Adapter for redis storage.

Parameters
null | array | Traversable | RedisOptions$options
See Also

Member Function Documentation

clearByNamespace (   $namespace)

Remove items of given namespace.

Parameters
string$namespace
Returns
bool

Implements ClearByNamespaceInterface.

clearByPrefix (   $prefix)

Remove items matching given prefix.

Parameters
string$prefix
Returns
bool

Implements ClearByPrefixInterface.

flush ( )

Flush currently set DB.

Returns
bool
Exceptions
Exception\RuntimeException

Implements FlushableInterface.

getOptions ( )

Get options.

Returns
RedisOptions
See Also
setOptions()

Implements StorageInterface.

getRedisResource ( )
protected

Get Redis resource.

Returns
RedisResource
getTotalSpace ( )

Get total space in bytes.

Returns
int|float

Implements TotalSpaceCapableInterface.

internalAddItem ( $normalizedKey,
$value 
)
protected

Add an item.

Parameters
string$normalizedKey
mixed$value
Returns
bool
Exceptions
Exception\RuntimeException

To ensure expected behaviour, we stick with the "setnx" method. This means we only set the ttl after the key/value has been successfully set.

internalDecrementItem ( $normalizedKey,
$value 
)
protected

Internal method to decrement an item.

Parameters
string$normalizedKey
int$value
Returns
int|bool The new value on success, false on failure
Exceptions
Exception\RuntimeException
internalGetCapabilities ( )
protected

Internal method to get capabilities of this adapter.

Returns
Capabilities
internalGetItem ( $normalizedKey,
$success = null,
$casToken = null 
)
protected

Internal method to get an item.

Parameters
string&$normalizedKeyKey where to store data
bool&$successIf the operation was successfull
mixed&$casTokenToken
Returns
mixed Data on success, false on key not found
Exceptions
Exception\RuntimeException
internalGetItems ( array &  $normalizedKeys)
protected

Internal method to get multiple items.

Parameters
array&$normalizedKeysArray of keys to be obtained
Returns
array Associative array of keys and values
Exceptions
Exception\RuntimeException
internalGetMetadata ( $normalizedKey)
protected

Exceptions
Exception\ExceptionInterface
internalHasItem ( $normalizedKey)
protected

Internal method to test if an item exists.

Parameters
string&$normalizedKeyNormalized key which will be checked
Returns
bool
Exceptions
Exception\RuntimeException
internalIncrementItem ( $normalizedKey,
$value 
)
protected

Internal method to increment an item.

Parameters
string$normalizedKey
int$value
Returns
int|bool The new value on success, false on failure
Exceptions
Exception\RuntimeException
internalRemoveItem ( $normalizedKey)
protected

Internal method to remove an item.

Parameters
string&$normalizedKeyKey which will be removed
Returns
bool
Exceptions
Exception\RuntimeException
internalSetItem ( $normalizedKey,
$value 
)
protected

Internal method to store an item.

Parameters
string&$normalizedKeyKey in Redis under which value will be saved
mixed&$valueValue to store under cache key
Returns
bool
Exceptions
Exception\RuntimeException
internalSetItems ( array &  $normalizedKeyValuePairs)
protected

Internal method to store multiple items.

Parameters
array&$normalizedKeyValuePairsAn array of normalized key/value pairs
Returns
array Array of not stored keys
Exceptions
Exception\RuntimeException
internalTouchItem ( $normalizedKey)
protected

Internal method to touch an item.

Parameters
string&$normalizedKeyKey which will be touched
Returns
bool
Exceptions
Exception\RuntimeException
preSerialize (   $value)
protected

Pre-Serialize value before putting it to the redis extension The reason for this is the buggy extension version < 2.5.7 which is producing a segfault on storing NULL as long as no serializer was configured.

https://github.com/zendframework/zend-cache/issues/88

setOptions (   $options)

Set options.

Parameters
array | Traversable | RedisOptions$options
Returns
Redis
See Also
getOptions()

Implements StorageInterface.

Member Data Documentation

$initialized = false
protected
$namespacePrefix = ''
protected
$resourceId
protected
$resourceManager
protected