FileCache

Type
Class
Namespace
Craft
Inherits
Craft\FileCache » CFileCache » CCache » CApplicationComponent » CComponent
Implements
ArrayAccess, IApplicationComponent, ICache
Since
1.0

Class FileCache

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$behaviorsarray – The behaviors that should be attached to this component.
$cacheFileModeinteger – The permission to be set for new cache files.
$cacheFileSuffixstring – Cache file suffix.
$cachePathstring – The directory to store cache files.
$cachePathModeinteger – The permission to be set for directory to store cache files This value will be used by PHP chmod function.
$directoryLevelinteger – The level of sub-directories to store cache files.
$embedExpiryboolean – Whether cache entry expiration time should be embedded into a physical file.
$hashKeyboolean – Whether to md5-hash the cache key for normalization purposes.
$keyPrefixstring – A string prefixed to every cache key so that it is unique.
$serializerarray, boolean – The functions used to serialize and unserialize cached data.

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets 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. Nothing will be done if the cache already contains the key.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
canGetProperty()Determines whether a property can be read.
canSetProperty()Determines whether a property can be set.
delete()Deletes a value with the specified key from cache
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
evaluateExpression()Evaluates a PHP expression or callback under the context of this component.
flush()Deletes all values from cache.
gc()Removes expired cache files.
get()Retrieves a value from cache with a specified key.
getEventHandlers()Returns the list of attached event handlers for an event.
getGCProbability()
getIsInitialized()Checks if this application component has been initialized.
hasEvent()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
init()Override so we can set a custom file cache path.
mget()Retrieves multiple values from cache with the specified keys.
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.
raiseEvent()Raises an event.
set()Stores a value identified by a key into cache. If the cache already contains such a key, the existing value and expiration time will be replaced with the new ones.
setGCProbability()

add()

Stores a value identified by a key into cache if the cache does not contain this key. Nothing will be done if the cache already contains the key.

View source

Arguments

  • $id (string) – The key identifying the value to be cached
  • $value (mixed) – The value to be cached
  • $expire (integer) – The number of seconds in which the cached value will expire. 0 means never expire.
  • $dependency (\ICacheDependency) – Dependency of the cached item. If the dependency changes, the item is labeled invalid.

Returns

boolean – True if the value is successfully stored into cache, false otherwise.

Signature

public boolean add ( $id, $value, $expire = null, $dependency = null )

init()

Override so we can set a custom file cache path.

View source

Returns

null

Signature

public null init ( )

set()

Stores a value identified by a key into cache. If the cache already contains such a key, the existing value and expiration time will be replaced with the new ones.

View source

Arguments

  • $id (string) – The key identifying the value to be cached
  • $value (mixed) – The value to be cached
  • $expire (integer) – The number of seconds in which the cached value will expire. 0 means never expire.
  • $dependency (\ICacheDependency) – Dependency of the cached item. If the dependency changes, the item is labeled invalid.

Returns

boolean – True if the value is successfully stored into cache, false otherwise.

Signature

public boolean set ( $id, $value, $expire = null, $dependency = null )

Protected Methods

MethodDescription
addValue()Stores a value identified by a key into cache if the cache does not contain this key.
deleteValue()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()Deletes all values from cache.
generateUniqueKey()
getCacheFile()Returns the cache file path given the 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. This is the implementation of the method declared in the parent class.

setValue()

Stores a value identified by a key in cache. This is the implementation of the method declared in the parent class.

View source

Arguments

  • $key (string) – The key identifying the value to be cached
  • $value (string) – The value to be cached
  • $expire (integer) – The number of seconds in which the cached value will expire. 0 means never expire.

Returns

boolean – True if the value is successfully stored into cache, false otherwise.

Signature

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