Свойство | Тип | Описание | |
---|---|---|---|
$cacheFileSuffix | cache file suffix. Defaults to '.bin'. | ||
$cachePath | the directory to store cache files. You may use path alias here. If not set, it will use the "cache" subdirectory under the application runtime path. | ||
$dirMode | the permission to be set for newly created directories. This value will be used by PHP chmod() function. No umask will be applied. Defaults to 0775, meaning the directory is read-writable by owner and group, but read-only for other users. | ||
$directoryLevel | the level of sub-directories to store cache files. Defaults to 1. If the system has huge number of cache files (e.g. one million), you may use a bigger value (usually no bigger than 3). Using sub-directories is mainly to ensure the file system is not over burdened with a single directory having too many files. | ||
$fileMode | the permission to be set for newly created cache files. This value will be used by PHP chmod() function. No umask will be applied. If not set, the permission will be determined by the current environment. | ||
$gcProbability | the probability (parts per million) that garbage collection (GC) should be performed when storing a piece of data in the cache. Defaults to 10, meaning 0.001% chance. This number should be between 0 and 1000000. A value 0 means no GC will be performed at all. | ||
$keyPrefix | a string prefixed to every cache key. This is needed when you store cache data under the same [[cachePath]] for different applications to avoid conflict. To ensure interoperability, only alphanumeric characters should be used. |
Метод | Описание | |
---|---|---|
exists ( mixed $key ) : boolean | Checks whether a specified key exists in the cache. | |
gc ( boolean $force = false, boolean $expiredOnly = true ) | Removes expired cache files. | |
init ( ) | Initializes this component by ensuring the existence of the cache path. |
Метод | Описание | |
---|---|---|
addValue ( string $key, string $value, integer $duration ) : boolean | Stores a value identified by a key into cache if the cache does not contain this key. | |
deleteValue ( string $key ) : boolean | Deletes a value with the specified key from cache This is the implementation of the method declared in the parent class. | |
flushValues ( ) : boolean | Deletes all values from cache. | |
gcRecursive ( string $path, boolean $expiredOnly ) | Recursively removing expired cache files under a directory. | |
getCacheFile ( string $key ) : string | Returns the cache file path given the cache key. | |
getValue ( string $key ) : string | false | Retrieves a value from cache with a specified key. | |
setValue ( string $key, string $value, integer $duration ) : boolean | Stores a value identified by a key in cache. |
protected addValue ( string $key, string $value, integer $duration ) : boolean | ||
$key | string | the key identifying the value to be cached |
$value | string | the value to be cached. Other types (if you have disabled [[serializer]]) unable to get is correct in [[getValue()]]. |
$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 |
protected deleteValue ( string $key ) : boolean | ||
$key | string | the key of the value to be deleted |
Результат | boolean | if no error happens during deletion |
protected flushValues ( ) : boolean | ||
Результат | boolean | whether the flush operation was successful. |
public gc ( boolean $force = false, boolean $expiredOnly = true ) | ||
$force | boolean | whether to enforce the garbage collection regardless of [[gcProbability]]. Defaults to false, meaning the actual deletion happens with the probability as specified by [[gcProbability]]. |
$expiredOnly | boolean | whether to removed expired cache files only. If false, all cache files under [[cachePath]] will be removed. |
protected gcRecursive ( string $path, boolean $expiredOnly ) | ||
$path | string | the directory under which expired cache files are removed. |
$expiredOnly | boolean | whether to only remove expired cache files. If false, all files under `$path` will be removed. |
protected getCacheFile ( string $key ) : string | ||
$key | string | cache key |
Результат | string | the cache file path |
public init ( ) |
protected setValue ( string $key, string $value, integer $duration ) : boolean | ||
$key | string | the key identifying the value to be cached |
$value | string | the value to be cached. Other types (If you have disabled [[serializer]]) unable to get is correct in [[getValue()]]. |
$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 $cachePath |
public $dirMode |
public $directoryLevel |
public $fileMode |
public $gcProbability |