FileCache

Type
Class
Namespace
craft\cache
Inherits
craft\cache\FileCache » yii\caching\FileCache (opens new window) » yii\caching\Cache (opens new window) » yii\base\Component (opens new window) » yii\base\BaseObject (opens new window)
Implements
yii\base\Configurable (opens new window), yii\caching\CacheInterface (opens new window)
Since
3.5.8

View source (opens new window)

# Public Properties

Property Description
behaviors (opens new window) yii\base\Behavior (opens new window) – List of behaviors attached to this component
cacheFileSuffix (opens new window) string (opens new window) – Cache file suffix.
cachePath (opens new window) string (opens new window) – The directory to store cache files.
defaultDuration (opens new window) integer (opens new window) – Default duration in seconds before a cache entry will expire.
dirMode (opens new window) integer (opens new window) – The permission to be set for newly created directories.
directoryLevel (opens new window) integer (opens new window) – The level of sub-directories to store cache files.
fileMode (opens new window) integer (opens new window) – The permission to be set for newly created cache files.
gcProbability (opens new window) integer (opens new window) – The probability (parts per million) that garbage collection (GC) should be performed when storing a piece of data in the cache.
keyPrefix (opens new window) string (opens new window) – A string prefixed to every cache key.
serializer (opens new window) null (opens new window), array (opens new window), false (opens new window) – The functions used to serialize and unserialize cached data.

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__clone() (opens new window) This method is called after the object is created by cloning an existing one.
__construct() (opens new window) Constructor.
__get() (opens new window) Returns the value of a component property.
__isset() (opens new window) Checks if a property is set, i.e. defined and not null.
__set() (opens new window) Sets the value of a component property.
__unset() (opens new window) Sets a component property to be null.
add() (opens new window) Stores a value identified by a key into cache if the cache does not contain this key.
attachBehavior() (opens new window) Attaches a behavior to this component.
attachBehaviors() (opens new window) Attaches a list of behaviors to the component.
behaviors() (opens new window) Returns a list of behaviors that this component should behave as.
buildKey() (opens new window) Builds a normalized cache key from a given key.
canGetProperty() (opens new window) Returns a value indicating whether a property can be read.
canSetProperty() (opens new window) Returns a value indicating whether a property can be set.
className() (opens new window) Returns the fully qualified name of this class.
delete() (opens new window) Deletes a value with the specified key from cache.
detachBehavior() (opens new window) Detaches a behavior from the component.
detachBehaviors() (opens new window) Detaches all behaviors from the component.
ensureBehaviors() (opens new window) Makes sure that the behaviors declared in behaviors() (opens new window) are attached to this component.
exists() (opens new window) Checks whether a specified key exists in the cache.
flush() (opens new window) Deletes all values from cache.
gc() (opens new window) Removes expired cache files.
get() (opens new window) Retrieves a value from cache with a specified key.
getBehavior() (opens new window) Returns the named behavior object.
getBehaviors() (opens new window) Returns all behaviors attached to this component.
getOrSet() (opens new window) Method combines both set() (opens new window) and get() (opens new window) methods to retrieve value identified by a $key, or to store the result of $callable execution if there is no cache available for the $key.
hasEventHandlers() (opens new window) Returns a value indicating whether there is any handler attached to the named event.
hasMethod() (opens new window) Returns a value indicating whether a method is defined.
hasProperty() (opens new window) Returns a value indicating whether a property is defined for this component.
init() (opens new window) Initializes this component by ensuring the existence of the cache path.
madd() (opens new window) Stores multiple items in cache. Each item contains a value identified by a key.
mget() (opens new window) Retrieves multiple values from cache with the specified keys.
mset() (opens new window) Stores multiple items in cache. Each item contains a value identified by a key.
multiAdd() (opens new window) Stores multiple items in cache. Each item contains a value identified by a key.
multiGet() (opens new window) Retrieves multiple values from cache with the specified keys.
multiSet() (opens new window) Stores multiple items in cache. Each item contains a value identified by a key.
off() (opens new window) Detaches an existing event handler from this component.
offsetExists() (opens new window) Returns whether there is a cache entry with a specified key.
offsetGet() (opens new window) Retrieves the value from cache with a specified key.
offsetSet() (opens new window) Stores the value identified by a key into cache.
offsetUnset() (opens new window) Deletes the value with the specified key from cache This method is required by the interface ArrayAccess (opens new window).
on() (opens new window) Attaches an event handler to an event.
set() (opens new window) Stores a value identified by a key into cache.
trigger() (opens new window) Triggers an event.

# Protected Methods

Method Description
addValue() (opens new window) Stores a value identified by a key into cache if the cache does not contain this key.
addValues() (opens new window) Adds multiple key-value pairs to cache.
deleteValue() (opens new window) Deletes a value with the specified key from cache This is the implementation of the method declared in the parent class.
flushValues() (opens new window) Deletes all values from cache.
gcRecursive() (opens new window) Recursively removing expired cache files under a directory.
getCacheFile() Returns the cache file path given the cache key.
getValue() (opens new window) Retrieves a value from cache with a specified key.
getValues() (opens new window) Retrieves multiple values from cache with the specified keys.
setValue() (opens new window) Stores a value identified by a key in cache.
setValues() (opens new window) Stores multiple key-value pairs in cache.

# getCacheFile()

Returns the cache file path given the cache key.

View source (opens new window)

Arguments

Returns

string (opens new window) – The cache file path