PHP Класс yii\redis\Cache

Redis Cache requires redis version 2.6.12 or higher to work properly. It needs to be configured with a redis Connection that is also configured as an application component. By default it will use the redis application component. See Cache manual for common cache operations that redis Cache supports. Unlike the Cache, redis Cache allows the expire parameter of [[set]], [[add]], [[mset]] and [[madd]] to be a floating point number, so you may specify the time in milliseconds (e.g. 0.1 will be 100 milliseconds). To use redis Cache as the cache application component, configure the application as follows, ~~~ [ 'components' => [ 'cache' => [ 'class' => 'yii\redis\Cache', 'redis' => [ 'hostname' => 'localhost', 'port' => 6379, 'database' => 0, ] ], ], ] ~~~ Or if you have configured the redis Connection as an application component, the following is sufficient: ~~~ [ 'components' => [ 'cache' => [ 'class' => 'yii\redis\Cache', 'redis' => 'redis' // id of the connection application component ], ], ] ~~~
С версии: 2.0
Автор: Carsten Brandt ([email protected])
Наследование: extends yii\caching\Cache
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$redis the Redis Connection object or the application component ID of the Redis Connection. This can also be an array that is used to create a redis Connection instance in case you do not want do configure redis connection as an application component. After the Cache object is created, if you want to change this property, you should only assign it with a Redis Connection object.

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

Метод Описание
exists ( mixed $key ) : boolean Checks whether a specified key exists in the cache.
init ( ) Initializes the redis Cache component.

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

Метод Описание
addValue ( $key, $value, $expire )
deleteValue ( $key )
flushValues ( )
getValue ( $key )
getValues ( $keys )
setValue ( $key, $value, $expire )
setValues ( $data, $expire )

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

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

protected addValue ( $key, $value, $expire )

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

protected deleteValue ( $key )

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

This can be faster than getting the value from the cache if the data is big. Note that this method does not check whether the dependency associated with the cached data, if there is any, has changed. So a call to [[get]] may return false while exists returns true.
public exists ( mixed $key ) : boolean
$key mixed a key identifying the cached value. This can be a simple string or a complex data structure consisting of factors representing the key.
Результат boolean true if a value exists in cache, false if the value is not in the cache or expired.

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

protected flushValues ( )

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

protected getValue ( $key )

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

protected getValues ( $keys )

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

This method will initialize the [[redis]] property to make sure it refers to a valid redis connection.
public init ( )

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

protected setValue ( $key, $value, $expire )

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

protected setValues ( $data, $expire )

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

$redis публичное свойство

the Redis Connection object or the application component ID of the Redis Connection. This can also be an array that is used to create a redis Connection instance in case you do not want do configure redis connection as an application component. After the Cache object is created, if you want to change this property, you should only assign it with a Redis Connection object.
public $redis