$_config
$_config : array
Runtime config
Storage engine for CakePHP caching
$_defaultConfig : array
The default cache configuration is overridden in most cache adapters. These are the keys that are common to all adapters. If overridden, this property is not used.
duration
Specify how long items in this cache configuration last.groups
List of groups or 'tags' associated to every key stored in this config.
handy for deleting a complete group from cache.prefix
Prefix appended to all entries. Good for when you need to share a keyspace
with either another cache config or another application.probability
Probability of hitting a cache gc cleanup. Setting to 0 will disable
cache::gc from ever being called automatically.warnOnWriteFailures
Some engines, such as ApcuEngine, may raise warnings on
write failures.setConfig(string|array $key, mixed|null $value = null, boolean $merge = true) : $this
Sets the config.
Setting a specific value:
$this->setConfig('key', $value);
Setting a nested value:
$this->setConfig('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->setConfig(['one' => 'value', 'another' => 'value']);
string|array | $key | The key to set, or a complete array of configs. |
mixed|null | $value | The value to set. |
boolean | $merge | Whether to recursively merge or overwrite existing config, defaults to true. |
When trying to set a key that is invalid.
getConfig(string|null $key = null, mixed $default = null) : mixed
Returns the config.
Reading the whole config:
$this->getConfig();
Reading a specific value:
$this->getConfig('key');
Reading a nested value:
$this->getConfig('some.nested.key');
Reading with default value:
$this->getConfig('some-key', 'default-value');
string|null | $key | The key to get or null for the whole config. |
mixed | $default | The return value when the key does not exist. |
Config value being read.
config(string|array|null $key = null, mixed|null $value = null, boolean $merge = true) : mixed
Gets/Sets the config.
Reading the whole config:
$this->config();
Reading a specific value:
$this->config('key');
Reading a nested value:
$this->config('some.nested.key');
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
string|array|null | $key | The key to get/set, or a complete array of configs. |
mixed|null | $value | The value to set. |
boolean | $merge | Whether to recursively merge or overwrite existing config, defaults to true. |
When trying to set a key that is invalid.
Config value being read, or the object itself on write operations.
configShallow(string|array $key, mixed|null $value = null) : $this
Merge provided config with existing config. Unlike `config()` which does a recursive merge for nested keys, this method does a simple merge.
Setting a specific value:
$this->configShallow('key', $value);
Setting a nested value:
$this->configShallow('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->configShallow(['one' => 'value', 'another' => 'value']);
string|array | $key | The key to set, or a complete array of configs. |
mixed|null | $value | The value to set. |
None found |
init(array $config = array()) : boolean
Initialize the cache engine
Called automatically by the cache frontend. Merge the runtime config with the defaults before use.
array | $config | Associative array of parameters for the engine |
True if the engine has been successfully initialized, false if not
None found |
gc(integer|null $expires = null) : void
Garbage collection
Permanently remove all expired and deleted data
integer|null | $expires | [optional] An expires timestamp, invalidating all data before. |
None found |
write(string $key, mixed $value) : boolean
Write value for a key into cache
string | $key | Identifier for the data |
mixed | $value | Data to be cached |
True if the data was successfully cached, false on failure
None found |
writeMany(array $data) : array
Write data for many keys into cache
array | $data | An array of data to be stored in the cache |
of bools for each key provided, true if the data was successfully cached, false on failure
None found |
read(string $key) : mixed
Read a key from the cache
string | $key | Identifier for the data |
The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
None found |
readMany(array $keys) : array
Read multiple keys from the cache
array | $keys | An array of identifiers for the data |
For each cache key (given as the array key) the cache data associated or false if the data doesn't exist, has expired, or if there was an error fetching it
None found |
increment(string $key, integer $offset = 1) : boolean|integer
Increment a number under the key and return incremented value
string | $key | Identifier for the data |
integer | $offset | How much to add |
New incremented value, false otherwise
None found |
decrement(string $key, integer $offset = 1) : boolean|integer
Decrement a number under the key and return decremented value
string | $key | Identifier for the data |
integer | $offset | How much to subtract |
New incremented value, false otherwise
None found |
delete(string $key) : boolean
Delete a key from the cache
string | $key | Identifier for the data |
True if the value was successfully deleted, false if it didn't exist or couldn't be removed
None found |
clear(boolean $check) : boolean
Delete all keys from the cache
boolean | $check | if true will check expiration, otherwise delete all |
True if the cache was successfully cleared, false otherwise
None found |
deleteMany(array $keys) : array
Deletes keys from the cache
array | $keys | An array of identifiers for the data |
For each provided cache key (given back as the array key) true if the value was successfully deleted, false if it didn't exist or couldn't be removed
None found |
add(string $key, mixed $value) : boolean
Add a key to the cache if it does not already exist.
Defaults to a non-atomic implementation. Subclasses should prefer atomic implementations.
string | $key | Identifier for the data. |
mixed | $value | Data to be cached. |
True if the data was successfully cached, false on failure.
None found |
clearGroup(string $group) : boolean
Clears all values belonging to a group. Is up to the implementing engine to decide whether actually delete the keys or just simulate it to achieve the same result.
string | $group | name of the group to be cleared |
None found |
groups() : array
Does whatever initialization for each group is required and returns the `group value` for each of them, this is the token representing each group in the cache key
None found |
key(string $key) : boolean|string
Generates a safe key for use with cache engine storage engines.
string | $key | the key passed over |
string key or false
None found |
_configRead(string|null $key) : mixed
Reads a config key.
string|null | $key | Key to read. |
None found |
_configWrite(string|array $key, mixed $value, boolean|string $merge = false) : void
Writes a config key.
string|array | $key | Key to write to. |
mixed | $value | Value to write. |
boolean|string | $merge | True to merge recursively, 'shallow' for simple merge, false to overwrite, defaults to false. |
if attempting to clobber existing config
None found |
_configDelete(string $key) : void
Deletes a single config key.
string | $key | Key to delete. |
if attempting to clobber existing config
None found |
_key(string $key) : mixed
Generates a safe key, taking account of the configured key prefix
string | $key | the key passed over |
If key's value is empty
string $key or false
None found |
warning(string $message) : void
Cache Engines may trigger warnings if they encounter failures during operation, if option warnOnWriteFailures is set to true.
string | $message | The warning message. |
None found |