Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/flow-flo.../libs/cakephp/cache
File: Cache.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
[2] Fix | Delete
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[3] Fix | Delete
*
[4] Fix | Delete
* Licensed under The MIT License
[5] Fix | Delete
* For full copyright and license information, please see the LICENSE.txt
[6] Fix | Delete
* Redistributions of files must retain the above copyright notice.
[7] Fix | Delete
*
[8] Fix | Delete
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[9] Fix | Delete
* @link https://cakephp.org CakePHP(tm) Project
[10] Fix | Delete
* @since 1.2.0
[11] Fix | Delete
* @license https://opensource.org/licenses/mit-license.php MIT License
[12] Fix | Delete
*/
[13] Fix | Delete
namespace Cake\Cache;
[14] Fix | Delete
[15] Fix | Delete
use Cake\Cache\Engine\NullEngine;
[16] Fix | Delete
use Cake\Core\ObjectRegistry;
[17] Fix | Delete
use Cake\Core\StaticConfigTrait;
[18] Fix | Delete
use InvalidArgumentException;
[19] Fix | Delete
use RuntimeException;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Cache provides a consistent interface to Caching in your application. It allows you
[23] Fix | Delete
* to use several different Cache engines, without coupling your application to a specific
[24] Fix | Delete
* implementation. It also allows you to change out cache storage or configuration without effecting
[25] Fix | Delete
* the rest of your application.
[26] Fix | Delete
*
[27] Fix | Delete
* ### Configuring Cache engines
[28] Fix | Delete
*
[29] Fix | Delete
* You can configure Cache engines in your application's `Config/cache.php` file.
[30] Fix | Delete
* A sample configuration would be:
[31] Fix | Delete
*
[32] Fix | Delete
* ```
[33] Fix | Delete
* Cache::config('shared', [
[34] Fix | Delete
* 'className' => 'Cake\Cache\Engine\ApcuEngine',
[35] Fix | Delete
* 'prefix' => 'my_app_'
[36] Fix | Delete
* ]);
[37] Fix | Delete
* ```
[38] Fix | Delete
*
[39] Fix | Delete
* This would configure an APCu cache engine to the 'shared' alias. You could then read and write
[40] Fix | Delete
* to that cache alias by using it for the `$config` parameter in the various Cache methods.
[41] Fix | Delete
*
[42] Fix | Delete
* In general all Cache operations are supported by all cache engines.
[43] Fix | Delete
* However, Cache::increment() and Cache::decrement() are not supported by File caching.
[44] Fix | Delete
*
[45] Fix | Delete
* There are 7 built-in caching engines:
[46] Fix | Delete
*
[47] Fix | Delete
* - `ApcuEngine` - Uses the APCu object cache, one of the fastest caching engines.
[48] Fix | Delete
* - `ArrayEngine` - Uses only memory to store all data, not actually a persistent engine.
[49] Fix | Delete
* Can be useful in test or CLI environment.
[50] Fix | Delete
* - `FileEngine` - Uses simple files to store content. Poor performance, but good for
[51] Fix | Delete
* storing large objects, or things that are not IO sensitive. Well suited to development
[52] Fix | Delete
* as it is an easy cache to inspect and manually flush.
[53] Fix | Delete
* - `MemcacheEngine` - Uses the PECL::Memcache extension and Memcached for storage.
[54] Fix | Delete
* Fast reads/writes, and benefits from memcache being distributed.
[55] Fix | Delete
* - `RedisEngine` - Uses redis and php-redis extension to store cache data.
[56] Fix | Delete
* - `WincacheEngine` - Uses Windows Cache Extension for PHP. Supports wincache 1.1.0 and higher.
[57] Fix | Delete
* This engine is recommended to people deploying on windows with IIS.
[58] Fix | Delete
* - `XcacheEngine` - Uses the Xcache extension, an alternative to APCu.
[59] Fix | Delete
*
[60] Fix | Delete
* See Cache engine documentation for expected configuration keys.
[61] Fix | Delete
*
[62] Fix | Delete
* @see config/app.php for configuration settings
[63] Fix | Delete
*/
[64] Fix | Delete
class Cache
[65] Fix | Delete
{
[66] Fix | Delete
use StaticConfigTrait;
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* An array mapping url schemes to fully qualified caching engine
[70] Fix | Delete
* class names.
[71] Fix | Delete
*
[72] Fix | Delete
* @var string[]
[73] Fix | Delete
*/
[74] Fix | Delete
protected static $_dsnClassMap = [
[75] Fix | Delete
'array' => 'Cake\Cache\Engine\ArrayEngine',
[76] Fix | Delete
'apc' => 'Cake\Cache\Engine\ApcuEngine', // @deprecated Since 3.6. Use apcu instead.
[77] Fix | Delete
'apcu' => 'Cake\Cache\Engine\ApcuEngine',
[78] Fix | Delete
'file' => 'Cake\Cache\Engine\FileEngine',
[79] Fix | Delete
'memcached' => 'Cake\Cache\Engine\MemcachedEngine',
[80] Fix | Delete
'null' => 'Cake\Cache\Engine\NullEngine',
[81] Fix | Delete
'redis' => 'Cake\Cache\Engine\RedisEngine',
[82] Fix | Delete
'wincache' => 'Cake\Cache\Engine\WincacheEngine',
[83] Fix | Delete
'xcache' => 'Cake\Cache\Engine\XcacheEngine',
[84] Fix | Delete
];
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* Flag for tracking whether or not caching is enabled.
[88] Fix | Delete
*
[89] Fix | Delete
* @var bool
[90] Fix | Delete
*/
[91] Fix | Delete
protected static $_enabled = true;
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Group to Config mapping
[95] Fix | Delete
*
[96] Fix | Delete
* @var array
[97] Fix | Delete
*/
[98] Fix | Delete
protected static $_groups = [];
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Cache Registry used for creating and using cache adapters.
[102] Fix | Delete
*
[103] Fix | Delete
* @var \Cake\Core\ObjectRegistry
[104] Fix | Delete
*/
[105] Fix | Delete
protected static $_registry;
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Returns the Cache Registry instance used for creating and using cache adapters.
[109] Fix | Delete
*
[110] Fix | Delete
* @return \Cake\Core\ObjectRegistry
[111] Fix | Delete
*/
[112] Fix | Delete
public static function getRegistry()
[113] Fix | Delete
{
[114] Fix | Delete
if (!static::$_registry) {
[115] Fix | Delete
static::$_registry = new CacheRegistry();
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
return static::$_registry;
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
/**
[122] Fix | Delete
* Sets the Cache Registry instance used for creating and using cache adapters.
[123] Fix | Delete
*
[124] Fix | Delete
* Also allows for injecting of a new registry instance.
[125] Fix | Delete
*
[126] Fix | Delete
* @param \Cake\Core\ObjectRegistry $registry Injectable registry object.
[127] Fix | Delete
* @return void
[128] Fix | Delete
*/
[129] Fix | Delete
public static function setRegistry(ObjectRegistry $registry)
[130] Fix | Delete
{
[131] Fix | Delete
static::$_registry = $registry;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
/**
[135] Fix | Delete
* Returns the Cache Registry instance used for creating and using cache adapters.
[136] Fix | Delete
* Also allows for injecting of a new registry instance.
[137] Fix | Delete
*
[138] Fix | Delete
* @param \Cake\Core\ObjectRegistry|null $registry Injectable registry object.
[139] Fix | Delete
* @return \Cake\Core\ObjectRegistry
[140] Fix | Delete
* @deprecated Deprecated since 3.5. Use getRegistry() and setRegistry() instead.
[141] Fix | Delete
*/
[142] Fix | Delete
public static function registry(ObjectRegistry $registry = null)
[143] Fix | Delete
{
[144] Fix | Delete
deprecationWarning('Use Cache::getRegistry() and Cache::setRegistry() instead.');
[145] Fix | Delete
if ($registry) {
[146] Fix | Delete
static::setRegistry($registry);
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
return static::getRegistry();
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
/**
[153] Fix | Delete
* Finds and builds the instance of the required engine class.
[154] Fix | Delete
*
[155] Fix | Delete
* @param string $name Name of the config array that needs an engine instance built
[156] Fix | Delete
* @return void
[157] Fix | Delete
* @throws \InvalidArgumentException When a cache engine cannot be created.
[158] Fix | Delete
*/
[159] Fix | Delete
protected static function _buildEngine($name)
[160] Fix | Delete
{
[161] Fix | Delete
$registry = static::getRegistry();
[162] Fix | Delete
[163] Fix | Delete
if (empty(static::$_config[$name]['className'])) {
[164] Fix | Delete
throw new InvalidArgumentException(
[165] Fix | Delete
sprintf('The "%s" cache configuration does not exist.', $name)
[166] Fix | Delete
);
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
$config = static::$_config[$name];
[170] Fix | Delete
[171] Fix | Delete
try {
[172] Fix | Delete
$registry->load($name, $config);
[173] Fix | Delete
} catch (RuntimeException $e) {
[174] Fix | Delete
if (!array_key_exists('fallback', $config)) {
[175] Fix | Delete
$registry->set($name, new NullEngine());
[176] Fix | Delete
trigger_error($e->getMessage(), E_USER_WARNING);
[177] Fix | Delete
[178] Fix | Delete
return;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
if ($config['fallback'] === false) {
[182] Fix | Delete
throw $e;
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
if ($config['fallback'] === $name) {
[186] Fix | Delete
throw new InvalidArgumentException(sprintf('"%s" cache configuration cannot fallback to itself.', $name), null, $e);
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
$fallbackEngine = clone static::engine($config['fallback']);
[190] Fix | Delete
$newConfig = $config + ['groups' => [], 'prefix' => null];
[191] Fix | Delete
$fallbackEngine->setConfig('groups', $newConfig['groups'], false);
[192] Fix | Delete
if ($newConfig['prefix']) {
[193] Fix | Delete
$fallbackEngine->setConfig('prefix', $newConfig['prefix'], false);
[194] Fix | Delete
}
[195] Fix | Delete
$registry->set($name, $fallbackEngine);
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
if ($config['className'] instanceof CacheEngine) {
[199] Fix | Delete
$config = $config['className']->getConfig();
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
if (!empty($config['groups'])) {
[203] Fix | Delete
foreach ($config['groups'] as $group) {
[204] Fix | Delete
static::$_groups[$group][] = $name;
[205] Fix | Delete
static::$_groups[$group] = array_unique(static::$_groups[$group]);
[206] Fix | Delete
sort(static::$_groups[$group]);
[207] Fix | Delete
}
[208] Fix | Delete
}
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* Fetch the engine attached to a specific configuration name.
[213] Fix | Delete
*
[214] Fix | Delete
* If the cache engine & configuration are missing an error will be
[215] Fix | Delete
* triggered.
[216] Fix | Delete
*
[217] Fix | Delete
* @param string $config The configuration name you want an engine for.
[218] Fix | Delete
* @return \Cake\Cache\CacheEngine When caching is disabled a null engine will be returned.
[219] Fix | Delete
* @deprecated 3.7.0 Use Cache::pool() instead. In 4.0 all cache engines will implement the
[220] Fix | Delete
* PSR16 interface and this method does not return objects implementing that interface.
[221] Fix | Delete
*/
[222] Fix | Delete
public static function engine($config)
[223] Fix | Delete
{
[224] Fix | Delete
if (!static::$_enabled) {
[225] Fix | Delete
return new NullEngine();
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
$registry = static::getRegistry();
[229] Fix | Delete
[230] Fix | Delete
if (isset($registry->{$config})) {
[231] Fix | Delete
return $registry->{$config};
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
static::_buildEngine($config);
[235] Fix | Delete
[236] Fix | Delete
return $registry->{$config};
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
/**
[240] Fix | Delete
* Get a SimpleCacheEngine object for the named cache pool.
[241] Fix | Delete
*
[242] Fix | Delete
* @param string $config The name of the configured cache backend.
[243] Fix | Delete
* @return \Cake\Cache\SimpleCacheEngine
[244] Fix | Delete
*/
[245] Fix | Delete
public static function pool($config)
[246] Fix | Delete
{
[247] Fix | Delete
return new SimpleCacheEngine(static::engine($config));
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
/**
[251] Fix | Delete
* Garbage collection
[252] Fix | Delete
*
[253] Fix | Delete
* Permanently remove all expired and deleted data
[254] Fix | Delete
*
[255] Fix | Delete
* @param string $config [optional] The config name you wish to have garbage collected. Defaults to 'default'
[256] Fix | Delete
* @param int|null $expires [optional] An expires timestamp. Defaults to NULL
[257] Fix | Delete
* @return void
[258] Fix | Delete
* @deprecated 3.7.0 Will be removed in 4.0
[259] Fix | Delete
*/
[260] Fix | Delete
public static function gc($config = 'default', $expires = null)
[261] Fix | Delete
{
[262] Fix | Delete
$engine = static::engine($config);
[263] Fix | Delete
$engine->gc($expires);
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
/**
[267] Fix | Delete
* Write data for key into cache.
[268] Fix | Delete
*
[269] Fix | Delete
* ### Usage:
[270] Fix | Delete
*
[271] Fix | Delete
* Writing to the active cache config:
[272] Fix | Delete
*
[273] Fix | Delete
* ```
[274] Fix | Delete
* Cache::write('cached_data', $data);
[275] Fix | Delete
* ```
[276] Fix | Delete
*
[277] Fix | Delete
* Writing to a specific cache config:
[278] Fix | Delete
*
[279] Fix | Delete
* ```
[280] Fix | Delete
* Cache::write('cached_data', $data, 'long_term');
[281] Fix | Delete
* ```
[282] Fix | Delete
*
[283] Fix | Delete
* @param string $key Identifier for the data
[284] Fix | Delete
* @param mixed $value Data to be cached - anything except a resource
[285] Fix | Delete
* @param string $config Optional string configuration name to write to. Defaults to 'default'
[286] Fix | Delete
* @return bool True if the data was successfully cached, false on failure
[287] Fix | Delete
*/
[288] Fix | Delete
public static function write($key, $value, $config = 'default')
[289] Fix | Delete
{
[290] Fix | Delete
if (is_resource($value)) {
[291] Fix | Delete
return false;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
$backend = static::pool($config);
[295] Fix | Delete
$success = $backend->set($key, $value);
[296] Fix | Delete
if ($success === false && $value !== '') {
[297] Fix | Delete
trigger_error(
[298] Fix | Delete
sprintf(
[299] Fix | Delete
"%s cache was unable to write '%s' to %s cache",
[300] Fix | Delete
$config,
[301] Fix | Delete
$key,
[302] Fix | Delete
get_class($backend)
[303] Fix | Delete
),
[304] Fix | Delete
E_USER_WARNING
[305] Fix | Delete
);
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
return $success;
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
/**
[312] Fix | Delete
* Write data for many keys into cache.
[313] Fix | Delete
*
[314] Fix | Delete
* ### Usage:
[315] Fix | Delete
*
[316] Fix | Delete
* Writing to the active cache config:
[317] Fix | Delete
*
[318] Fix | Delete
* ```
[319] Fix | Delete
* Cache::writeMany(['cached_data_1' => 'data 1', 'cached_data_2' => 'data 2']);
[320] Fix | Delete
* ```
[321] Fix | Delete
*
[322] Fix | Delete
* Writing to a specific cache config:
[323] Fix | Delete
*
[324] Fix | Delete
* ```
[325] Fix | Delete
* Cache::writeMany(['cached_data_1' => 'data 1', 'cached_data_2' => 'data 2'], 'long_term');
[326] Fix | Delete
* ```
[327] Fix | Delete
*
[328] Fix | Delete
* @param array $data An array of data to be stored in the cache
[329] Fix | Delete
* @param string $config Optional string configuration name to write to. Defaults to 'default'
[330] Fix | Delete
* @return array of bools for each key provided, indicating true for success or false for fail
[331] Fix | Delete
* @throws \RuntimeException
[332] Fix | Delete
*/
[333] Fix | Delete
public static function writeMany($data, $config = 'default')
[334] Fix | Delete
{
[335] Fix | Delete
$engine = static::engine($config);
[336] Fix | Delete
[337] Fix | Delete
$return = $engine->writeMany($data);
[338] Fix | Delete
foreach ($return as $key => $success) {
[339] Fix | Delete
if ($success === false && $data[$key] !== '') {
[340] Fix | Delete
throw new RuntimeException(sprintf(
[341] Fix | Delete
'%s cache was unable to write \'%s\' to %s cache',
[342] Fix | Delete
$config,
[343] Fix | Delete
$key,
[344] Fix | Delete
get_class($engine)
[345] Fix | Delete
));
[346] Fix | Delete
}
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
return $return;
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
/**
[353] Fix | Delete
* Read a key from the cache.
[354] Fix | Delete
*
[355] Fix | Delete
* ### Usage:
[356] Fix | Delete
*
[357] Fix | Delete
* Reading from the active cache configuration.
[358] Fix | Delete
*
[359] Fix | Delete
* ```
[360] Fix | Delete
* Cache::read('my_data');
[361] Fix | Delete
* ```
[362] Fix | Delete
*
[363] Fix | Delete
* Reading from a specific cache configuration.
[364] Fix | Delete
*
[365] Fix | Delete
* ```
[366] Fix | Delete
* Cache::read('my_data', 'long_term');
[367] Fix | Delete
* ```
[368] Fix | Delete
*
[369] Fix | Delete
* @param string $key Identifier for the data
[370] Fix | Delete
* @param string $config optional name of the configuration to use. Defaults to 'default'
[371] Fix | Delete
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
[372] Fix | Delete
*/
[373] Fix | Delete
public static function read($key, $config = 'default')
[374] Fix | Delete
{
[375] Fix | Delete
// TODO In 4.x this needs to change to use pool()
[376] Fix | Delete
$engine = static::engine($config);
[377] Fix | Delete
[378] Fix | Delete
return $engine->read($key);
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
/**
[382] Fix | Delete
* Read multiple keys from the cache.
[383] Fix | Delete
*
[384] Fix | Delete
* ### Usage:
[385] Fix | Delete
*
[386] Fix | Delete
* Reading multiple keys from the active cache configuration.
[387] Fix | Delete
*
[388] Fix | Delete
* ```
[389] Fix | Delete
* Cache::readMany(['my_data_1', 'my_data_2]);
[390] Fix | Delete
* ```
[391] Fix | Delete
*
[392] Fix | Delete
* Reading from a specific cache configuration.
[393] Fix | Delete
*
[394] Fix | Delete
* ```
[395] Fix | Delete
* Cache::readMany(['my_data_1', 'my_data_2], 'long_term');
[396] Fix | Delete
* ```
[397] Fix | Delete
*
[398] Fix | Delete
* @param array $keys an array of keys to fetch from the cache
[399] Fix | Delete
* @param string $config optional name of the configuration to use. Defaults to 'default'
[400] Fix | Delete
* @return array An array containing, for each of the given $keys, the cached data or false if cached data could not be
[401] Fix | Delete
* retrieved.
[402] Fix | Delete
*/
[403] Fix | Delete
public static function readMany($keys, $config = 'default')
[404] Fix | Delete
{
[405] Fix | Delete
// In 4.x this needs to change to use pool()
[406] Fix | Delete
$engine = static::engine($config);
[407] Fix | Delete
[408] Fix | Delete
return $engine->readMany($keys);
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
/**
[412] Fix | Delete
* Increment a number under the key and return incremented value.
[413] Fix | Delete
*
[414] Fix | Delete
* @param string $key Identifier for the data
[415] Fix | Delete
* @param int $offset How much to add
[416] Fix | Delete
* @param string $config Optional string configuration name. Defaults to 'default'
[417] Fix | Delete
* @return int|false New value, or false if the data doesn't exist, is not integer,
[418] Fix | Delete
* or if there was an error fetching it.
[419] Fix | Delete
*/
[420] Fix | Delete
public static function increment($key, $offset = 1, $config = 'default')
[421] Fix | Delete
{
[422] Fix | Delete
$engine = static::pool($config);
[423] Fix | Delete
if (!is_int($offset) || $offset < 0) {
[424] Fix | Delete
return false;
[425] Fix | Delete
}
[426] Fix | Delete
[427] Fix | Delete
return $engine->increment($key, $offset);
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
/**
[431] Fix | Delete
* Decrement a number under the key and return decremented value.
[432] Fix | Delete
*
[433] Fix | Delete
* @param string $key Identifier for the data
[434] Fix | Delete
* @param int $offset How much to subtract
[435] Fix | Delete
* @param string $config Optional string configuration name. Defaults to 'default'
[436] Fix | Delete
* @return int|false New value, or false if the data doesn't exist, is not integer,
[437] Fix | Delete
* or if there was an error fetching it
[438] Fix | Delete
*/
[439] Fix | Delete
public static function decrement($key, $offset = 1, $config = 'default')
[440] Fix | Delete
{
[441] Fix | Delete
$engine = static::pool($config);
[442] Fix | Delete
if (!is_int($offset) || $offset < 0) {
[443] Fix | Delete
return false;
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
return $engine->decrement($key, $offset);
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
/**
[450] Fix | Delete
* Delete a key from the cache.
[451] Fix | Delete
*
[452] Fix | Delete
* ### Usage:
[453] Fix | Delete
*
[454] Fix | Delete
* Deleting from the active cache configuration.
[455] Fix | Delete
*
[456] Fix | Delete
* ```
[457] Fix | Delete
* Cache::delete('my_data');
[458] Fix | Delete
* ```
[459] Fix | Delete
*
[460] Fix | Delete
* Deleting from a specific cache configuration.
[461] Fix | Delete
*
[462] Fix | Delete
* ```
[463] Fix | Delete
* Cache::delete('my_data', 'long_term');
[464] Fix | Delete
* ```
[465] Fix | Delete
*
[466] Fix | Delete
* @param string $key Identifier for the data
[467] Fix | Delete
* @param string $config name of the configuration to use. Defaults to 'default'
[468] Fix | Delete
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
[469] Fix | Delete
*/
[470] Fix | Delete
public static function delete($key, $config = 'default')
[471] Fix | Delete
{
[472] Fix | Delete
$backend = static::pool($config);
[473] Fix | Delete
[474] Fix | Delete
return $backend->delete($key);
[475] Fix | Delete
}
[476] Fix | Delete
[477] Fix | Delete
/**
[478] Fix | Delete
* Delete many keys from the cache.
[479] Fix | Delete
*
[480] Fix | Delete
* ### Usage:
[481] Fix | Delete
*
[482] Fix | Delete
* Deleting multiple keys from the active cache configuration.
[483] Fix | Delete
*
[484] Fix | Delete
* ```
[485] Fix | Delete
* Cache::deleteMany(['my_data_1', 'my_data_2']);
[486] Fix | Delete
* ```
[487] Fix | Delete
*
[488] Fix | Delete
* Deleting from a specific cache configuration.
[489] Fix | Delete
*
[490] Fix | Delete
* ```
[491] Fix | Delete
* Cache::deleteMany(['my_data_1', 'my_data_2], 'long_term');
[492] Fix | Delete
* ```
[493] Fix | Delete
*
[494] Fix | Delete
* @param array $keys Array of cache keys to be deleted
[495] Fix | Delete
* @param string $config name of the configuration to use. Defaults to 'default'
[496] Fix | Delete
* @return array of boolean values that are true if the value was successfully deleted,
[497] Fix | Delete
* false if it didn't exist or couldn't be removed.
[498] Fix | Delete
*/
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function