PHP Класс Neos\Cache\Backend\RedisBackend

Redis is a noSQL database with very good scaling characteristics in proportion to the amount of entries and data size.
См. также: http://redis.io/
См. также: https://github.com/nicolasff/phpredis Available backend options: - defaultLifetime: The default lifetime of a cache entry - hostname: The hostname (or socket filepath) of the redis server - port: The TCP port of the redis server (will be ignored if connecting to a socket) - database: The database index that will be used. By default, Redis has 16 databases with index number 0 - 15 Requirements: - Redis 2.6.0+ (tested with 2.6.14 and 2.8.5) - phpredis with Redis 2.6 support, e.g. 2.2.4 (tested with 92782639b0329ff91658a0602a3d816446a3663d from 2014-01-06) Implementation based on ext:rediscache by Christopher Hlubek - networkteam GmbH Each Redis key contains a prefix built from the cache identifier, so one single database can be used for different caches. Cache entry data is stored in a simple key. Tags are stored in Sets. Since Redis < 2.8.0 does not provide a mechanism for iterating over keys, a separate list with all entries is populated
Наследование: extends AbstractBackend, implements Neos\Cache\Backend\TaggableBackendInterface, implements IterableBackendInterface, implements Neos\Cache\Backend\FreezableBackendInterface, implements Neos\Cache\Backend\PhpCapableBackendInterface, use trait RequireOnceFromValueTrait
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$compressionLevel integer
$database integer
$entryCursor Cursor used for iterating over cache entries
$frozen boolean
$hostname string
$port integer
$redis Redis

Открытые методы

Метод Описание
__construct ( EnvironmentConfiguration $environmentConfiguration, array $options ) Constructs this backend
collectGarbage ( ) : void This backend does not need an externally triggered garbage collection
current ( )
findIdentifiersByTag ( string $tag ) : array Finds and returns all cache entry identifiers which are tagged by the specified tag.
flush ( ) : void Removes all cache entries of this cache
flushByTag ( string $tag ) : integer Removes all cache entries of this cache which are tagged by the specified tag.
freeze ( ) : void Freezes this cache backend.
get ( string $entryIdentifier ) : mixed Loads data from the cache.
has ( string $entryIdentifier ) : boolean Checks if a cache entry with the specified identifier exists.
isFrozen ( ) : boolean Tells if this backend is frozen.
key ( )
next ( )
remove ( string $entryIdentifier ) : boolean Removes all cache entries matching the specified identifier.
rewind ( )
set ( string $entryIdentifier, string $data, array $tags = [], integer $lifetime = null ) : void Saves data in the cache.
setCompressionLevel ( integer $compressionLevel )
setDatabase ( integer $database ) Sets the database that will be used for this backend
setDefaultLifetime ( integer $lifetime ) : void Sets the default lifetime for this cache backend
setHostname ( string $hostname ) Sets the hostname or the socket of the Redis server
setPort ( string $port ) Sets the port of the Redis server.
setRedis ( Redis $redis = null )
valid ( )

Защищенные методы

Метод Описание
verifyRedisVersionIsSupported ( ) : void

Приватные методы

Метод Описание
buildKey ( $identifier ) : string
compress ( string $value ) : string
getRedisClient ( ) : Redis
uncompress ( string $value ) : string
useCompression ( ) : boolean

Описание методов

__construct() публичный Метод

Constructs this backend
public __construct ( EnvironmentConfiguration $environmentConfiguration, array $options )
$environmentConfiguration Neos\Cache\EnvironmentConfiguration
$options array Configuration options - depends on the actual backend

collectGarbage() публичный Метод

This backend does not need an externally triggered garbage collection
public collectGarbage ( ) : void
Результат void

current() публичный Метод

public current ( )

findIdentifiersByTag() публичный Метод

Finds and returns all cache entry identifiers which are tagged by the specified tag.
public findIdentifiersByTag ( string $tag ) : array
$tag string The tag to search for
Результат array An array with identifiers of all matching entries. An empty array if no entries matched

flush() публичный Метод

The flush method will use the EVAL command to flush all entries and tags for this cache in an atomic way.
public flush ( ) : void
Результат void

flushByTag() публичный Метод

Removes all cache entries of this cache which are tagged by the specified tag.
public flushByTag ( string $tag ) : integer
$tag string The tag the entries must have
Результат integer The number of entries which have been affected by this flush

freeze() публичный Метод

All data in a frozen backend remains unchanged and methods which try to add or modify data result in an exception thrown. Possible expiry times of individual cache entries are ignored. A frozen backend can only be thawn by calling the flush() method.
public freeze ( ) : void
Результат void

get() публичный Метод

Loads data from the cache.
public get ( string $entryIdentifier ) : mixed
$entryIdentifier string An identifier which describes the cache entry to load
Результат mixed The cache entry's content as a string or FALSE if the cache entry could not be loaded

has() публичный Метод

Checks if a cache entry with the specified identifier exists.
public has ( string $entryIdentifier ) : boolean
$entryIdentifier string An identifier specifying the cache entry
Результат boolean TRUE if such an entry exists, FALSE if not

isFrozen() публичный Метод

Tells if this backend is frozen.
public isFrozen ( ) : boolean
Результат boolean

key() публичный Метод

public key ( )

next() публичный Метод

public next ( )

remove() публичный Метод

Usually this only affects one entry but if - for what reason ever - old entries for the identifier still exist, they are removed as well.
public remove ( string $entryIdentifier ) : boolean
$entryIdentifier string Specifies the cache entry to remove
Результат boolean TRUE if (at least) an entry could be removed or FALSE if no entry was found

rewind() публичный Метод

public rewind ( )

set() публичный Метод

Saves data in the cache.
public set ( string $entryIdentifier, string $data, array $tags = [], integer $lifetime = null ) : void
$entryIdentifier string An identifier for this specific cache entry
$data string The data to be stored
$tags array Tags to associate with this cache entry. If the backend does not support tags, this option can be ignored.
$lifetime integer Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
Результат void

setCompressionLevel() публичный Метод

public setCompressionLevel ( integer $compressionLevel )
$compressionLevel integer

setDatabase() публичный Метод

Sets the database that will be used for this backend
public setDatabase ( integer $database )
$database integer Database that will be used

setDefaultLifetime() публичный Метод

Sets the default lifetime for this cache backend
public setDefaultLifetime ( integer $lifetime ) : void
$lifetime integer Default lifetime of this cache backend in seconds. If NULL is specified, the default lifetime is used. 0 means unlimited lifetime.
Результат void

setHostname() публичный Метод

Sets the hostname or the socket of the Redis server
public setHostname ( string $hostname )
$hostname string Hostname of the Redis server

setPort() публичный Метод

Leave this empty if you want to connect to a socket
public setPort ( string $port )
$port string Port of the Redis server

setRedis() публичный Метод

public setRedis ( Redis $redis = null )
$redis Redis

valid() публичный Метод

public valid ( )

verifyRedisVersionIsSupported() защищенный Метод

protected verifyRedisVersionIsSupported ( ) : void
Результат void

Описание свойств

$compressionLevel защищенное свойство

protected int $compressionLevel
Результат integer

$database защищенное свойство

protected int $database
Результат integer

$entryCursor защищенное свойство

Cursor used for iterating over cache entries
protected $entryCursor

$frozen защищенное свойство

protected bool $frozen
Результат boolean

$hostname защищенное свойство

protected string $hostname
Результат string

$port защищенное свойство

protected int $port
Результат integer

$redis защищенное свойство

protected Redis $redis
Результат Redis