DbCache

Type
Class
Namespace
Craft
Inherits
Craft\DbCache » CDbCache » CCache » CApplicationComponent » CComponent
Implements
ArrayAccess, IApplicationComponent, ICache
Since
2.0

DbCache implements a cache application component by storing cached data in a database.

DbCache stores cache data in a DB table named {@link cacheTableName}. If the table does not exist, it will be automatically created.

DbCache relies on PDO to access database. By default, it will use the database connection information stored in your craft/config/db.php file.

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$autoCreateCacheTableboolean – Whether the cache DB table should be created automatically if it does not exist.
$behaviorsarray – The behaviors that should be attached to this component.
$cacheTableNamestring – Name of the DB table to store cache content.
$connectionIDstring – The ID of the {@link CDbConnection} application component.
$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.
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.
get()Retrieves a value from cache with a specified key.
getDbConnection()
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()Initializes the application component.
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.
setDbConnection()Sets the DB connection used by the cache component.
setGCProbability()

getDbConnection()

Signature

public Craft\DbConnection getDbConnection ( )

Protected Methods

MethodDescription
addValue()Stores a value identified by a key into cache if the cache does not contain this key.
createCacheTable()
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.
gc()Removes the expired data values.
generateUniqueKey()
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.

createCacheTable()

View source

Arguments

Signature

protected void createCacheTable ( $db, $tableName )