Свойство | Тип | Описание | |
---|---|---|---|
$defaultDuration | default duration in seconds before a cache entry will expire. Default value is 0, meaning infinity. This value is used by Cache::set if the duration is not explicitly given. | ||
$keyPrefix | a string prefixed to every cache key so that it is unique globally in the whole cache storage. It is recommended that you set a unique cache key prefix for each application if the same cache storage is being used by different applications. To ensure interoperability, only alphanumeric characters should be used. | ||
$serializer | the functions used to serialize and unserialize cached data. Defaults to null, meaning using the default PHP serialize() and unserialize() functions. If you want to use some more efficient serializer (e.g. igbinary), you may configure this property with a two-element array. The first element specifies the serialization function, and the second the deserialization function. If this property is set false, data will be directly sent to and retrieved from the underlying cache component without any serialization or deserialization. You should not turn off serialization if you are using [[Dependency|cache dependency]], because it relies on data serialization. Also, some implementations of the cache can not correctly save and retrieve data different from a string type. |
Метод | Описание | |
---|---|---|
add ( mixed $key, mixed $value, integer $duration, yii\caching\Dependency $dependency = null ) : boolean | Stores a value identified by a key into cache if the cache does not contain this key. | |
buildKey ( mixed $key ) : string | Builds a normalized cache key from a given key. | |
delete ( mixed $key ) : boolean | Deletes a value with the specified key from cache | |
exists ( mixed $key ) : boolean | Checks whether a specified key exists in the cache. | |
flush ( ) : boolean | Deletes all values from cache. | |
get ( mixed $key ) : mixed | Retrieves a value from cache with a specified key. | |
madd ( array $items, integer $duration, yii\caching\Dependency $dependency = null ) : array | Stores multiple items in cache. Each item contains a value identified by a key. | |
mget ( string[] $keys ) : array | Retrieves multiple values from cache with the specified keys. | |
mset ( array $items, integer $duration, yii\caching\Dependency $dependency = null ) : array | Stores multiple items in cache. Each item contains a value identified by a key. | |
multiAdd ( array $items, integer $duration, yii\caching\Dependency $dependency = null ) : array | Stores multiple items in cache. Each item contains a value identified by a key. | |
multiGet ( string[] $keys ) : array | Retrieves multiple values from cache with the specified keys. | |
multiSet ( array $items, integer $duration, yii\caching\Dependency $dependency = null ) : array | Stores multiple items in cache. Each item contains a value identified by a key. | |
offsetExists ( string $key ) : boolean | Returns whether there is a cache entry with a specified key. | |
offsetGet ( string $key ) : mixed | Retrieves the value from cache with a specified key. | |
offsetSet ( string $key, mixed $value ) | Stores the value identified by a key into cache. | |
offsetUnset ( string $key ) | Deletes the value with the specified key from cache This method is required by the interface [[\ArrayAccess]]. | |
set ( mixed $key, mixed $value, integer $duration = null, yii\caching\Dependency $dependency = null ) : boolean | Stores a value identified by a key into cache. |
Метод | Описание | |
---|---|---|
addValue ( string $key, mixed $value, integer $duration ) : boolean | Stores a value identified by a key into cache if the cache does not contain this key. | |
addValues ( array $data, integer $duration ) : array | Adds multiple key-value pairs to cache. | |
deleteValue ( string $key ) : boolean | Deletes a value with the specified key from cache This method should be implemented by child classes to delete the data from actual cache storage. | |
flushValues ( ) : boolean | Deletes all values from cache. | |
getValue ( string $key ) : mixed | false | Retrieves a value from cache with a specified key. | |
getValues ( array $keys ) : array | Retrieves multiple values from cache with the specified keys. | |
setValue ( string $key, mixed $value, integer $duration ) : boolean | Stores a value identified by a key in cache. | |
setValues ( array $data, integer $duration ) : array | Stores multiple key-value pairs in cache. |
public add ( mixed $key, mixed $value, integer $duration, yii\caching\Dependency $dependency = null ) : boolean | ||
$key | mixed | a key identifying the value to be cached. This can be a simple string or a complex data structure consisting of factors representing the key. |
$value | mixed | the value to be cached |
$duration | integer | the number of seconds in which the cached value will expire. 0 means never expire. |
$dependency | yii\caching\Dependency | dependency of the cached item. If the dependency changes, the corresponding value in the cache will be invalidated when it is fetched via [[get()]]. This parameter is ignored if [[serializer]] is false. |
Результат | boolean | whether the value is successfully stored into cache |
abstract protected addValue ( string $key, mixed $value, integer $duration ) : boolean | ||
$key | string | the key identifying the value to be cached |
$value | mixed | the value to be cached. Most often it's a string. If you have disabled [[serializer]], it could be something else. |
$duration | integer | the number of seconds in which the cached value will expire. 0 means never expire. |
Результат | boolean | true if the value is successfully stored into cache, false otherwise |
abstract protected deleteValue ( string $key ) : boolean | ||
$key | string | the key of the value to be deleted |
Результат | boolean | if no error happens during deletion |
abstract protected flushValues ( ) : boolean | ||
Результат | boolean | whether the flush operation was successful. |
public get ( mixed $key ) : mixed | ||
$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. |
Результат | mixed | the value stored in cache, false if the value is not in the cache, expired, or the dependency associated with the cached data has changed. |
abstract protected getValue ( string $key ) : mixed | false | ||
$key | string | a unique key identifying the cached value |
Результат | mixed | false | the value stored in cache, false if the value is not in the cache or expired. Most often value is a string. If you have disabled [[serializer]], it could be something else. |
public madd ( array $items, integer $duration, yii\caching\Dependency $dependency = null ) : array | ||
$items | array | the items to be cached, as key-value pairs. |
$duration | integer | default number of seconds in which the cached values will expire. 0 means never expire. |
$dependency | yii\caching\Dependency | dependency of the cached items. If the dependency changes, the corresponding values in the cache will be invalidated when it is fetched via [[get()]]. This parameter is ignored if [[serializer]] is false. |
Результат | array | array of failed keys |
public mget ( string[] $keys ) : array | ||
$keys | string[] | list of string keys identifying the cached values |
Результат | array | list of cached values corresponding to the specified keys. The array is returned in terms of (key, value) pairs. If a value is not cached or expired, the corresponding array value will be false. |
public mset ( array $items, integer $duration, yii\caching\Dependency $dependency = null ) : array | ||
$items | array | the items to be cached, as key-value pairs. |
$duration | integer | default number of seconds in which the cached values will expire. 0 means never expire. |
$dependency | yii\caching\Dependency | dependency of the cached items. If the dependency changes, the corresponding values in the cache will be invalidated when it is fetched via [[get()]]. This parameter is ignored if [[serializer]] is false. |
Результат | array | array of failed keys |
public multiAdd ( array $items, integer $duration, yii\caching\Dependency $dependency = null ) : array | ||
$items | array | the items to be cached, as key-value pairs. |
$duration | integer | default number of seconds in which the cached values will expire. 0 means never expire. |
$dependency | yii\caching\Dependency | dependency of the cached items. If the dependency changes, the corresponding values in the cache will be invalidated when it is fetched via [[get()]]. This parameter is ignored if [[serializer]] is false. |
Результат | array | array of failed keys |
public multiGet ( string[] $keys ) : array | ||
$keys | string[] | list of string keys identifying the cached values |
Результат | array | list of cached values corresponding to the specified keys. The array is returned in terms of (key, value) pairs. If a value is not cached or expired, the corresponding array value will be false. |
public multiSet ( array $items, integer $duration, yii\caching\Dependency $dependency = null ) : array | ||
$items | array | the items to be cached, as key-value pairs. |
$duration | integer | default number of seconds in which the cached values will expire. 0 means never expire. |
$dependency | yii\caching\Dependency | dependency of the cached items. If the dependency changes, the corresponding values in the cache will be invalidated when it is fetched via [[get()]]. This parameter is ignored if [[serializer]] is false. |
Результат | array | array of failed keys |
public offsetExists ( string $key ) : boolean | ||
$key | string | a key identifying the cached value |
Результат | boolean |
public offsetUnset ( string $key ) | ||
$key | string | the key of the value to be deleted |
public set ( mixed $key, mixed $value, integer $duration = null, yii\caching\Dependency $dependency = null ) : boolean | ||
$key | mixed | a key identifying the value to be cached. This can be a simple string or a complex data structure consisting of factors representing the key. |
$value | mixed | the value to be cached |
$duration | integer | default duration in seconds before the cache will expire. If not set, default [[ttl]] value is used. |
$dependency | yii\caching\Dependency | dependency of the cached item. If the dependency changes, the corresponding value in the cache will be invalidated when it is fetched via [[get()]]. This parameter is ignored if [[serializer]] is false. |
Результат | boolean | whether the value is successfully stored into cache |
abstract protected setValue ( string $key, mixed $value, integer $duration ) : boolean | ||
$key | string | the key identifying the value to be cached |
$value | mixed | the value to be cached. Most often it's a string. If you have disabled [[serializer]], it could be something else. |
$duration | integer | the number of seconds in which the cached value will expire. 0 means never expire. |
Результат | boolean | true if the value is successfully stored into cache, false otherwise |
public $defaultDuration |
public $keyPrefix |
public $serializer |