Skip to content

FileCache ​

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

View source

Public Properties ​

PropertyDescription
behaviorsyii\base\Behavior – List of behaviors attached to this component.
cacheFileSuffixstring – Cache file suffix.
cachePathstring – The directory to store cache files.
defaultDurationinteger – Default duration in seconds before a cache entry will expire.
dirModeinteger – The permission to be set for newly created directories.
directoryLevelinteger – The level of sub-directories to store cache files.
fileModeinteger, null – The permission to be set for newly created cache files.
gcProbabilityinteger – The probability (parts per million) that garbage collection (GC) should be performed when storing a piece of data in the cache.
keyPrefixstring – A string prefixed to every cache key.
serializerarray, null, false – The functions used to serialize and unserialize cached data.

Public Methods ​

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

Protected Methods ​

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

getCacheFile() ​

Returns the cache file path given the normalized cache key.

View source

Arguments ​

  • $key

Returns ​

string – The cache file path