DbCache

Type
Class
Namespace
craft\cache
Inherits
craft\cache\DbCache » yii\caching\DbCache (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.4.14

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.
cacheTable (opens new window) string (opens new window) – Name of the DB table to store cache content.
db (opens new window) yii\db\Connection (opens new window), array (opens new window), string (opens new window) – The DB connection object or the application component ID of the DB connection.
defaultDuration (opens new window) integer (opens new window) – Default duration in seconds before a cache entry will expire.
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 so that it is unique globally in the whole cache storage.
serializer (opens new window) array (opens new window), null (opens new window), false (opens new window) – The functions used to serialize and unserialize cached data.

# Protected Properties

# 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 the expired data values.
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 the DbCache component.
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() 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.
getDataFieldName() (opens new window)
getDataFieldValue() (opens new window)
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.
isVarbinaryDataField() (opens new window)
setValue() Stores a value identified by a key in cache.
setValues() (opens new window) Stores multiple key-value pairs in cache.

# addValue()

Stores a value identified by a key into cache if the cache does not contain this key.

This is the implementation of the method declared in the parent class.

View source (opens new window)

Arguments

Returns

boolean (opens new window) – True if the value is successfully stored into cache, false otherwise

# setValue()

Stores a value identified by a key in cache.

This is the implementation of the method declared in the parent class.

View source (opens new window)

Arguments

Returns

boolean (opens new window) – True if the value is successfully stored into cache, false otherwise