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: CacheEngine.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\Core\InstanceConfigTrait;
[16] Fix | Delete
use InvalidArgumentException;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Storage engine for CakePHP caching
[20] Fix | Delete
*/
[21] Fix | Delete
abstract class CacheEngine
[22] Fix | Delete
{
[23] Fix | Delete
use InstanceConfigTrait;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* The default cache configuration is overridden in most cache adapters. These are
[27] Fix | Delete
* the keys that are common to all adapters. If overridden, this property is not used.
[28] Fix | Delete
*
[29] Fix | Delete
* - `duration` Specify how long items in this cache configuration last.
[30] Fix | Delete
* - `groups` List of groups or 'tags' associated to every key stored in this config.
[31] Fix | Delete
* handy for deleting a complete group from cache.
[32] Fix | Delete
* - `prefix` Prefix appended to all entries. Good for when you need to share a keyspace
[33] Fix | Delete
* with either another cache config or another application.
[34] Fix | Delete
* - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable
[35] Fix | Delete
* cache::gc from ever being called automatically.
[36] Fix | Delete
* - `warnOnWriteFailures` Some engines, such as ApcuEngine, may raise warnings on
[37] Fix | Delete
* write failures.
[38] Fix | Delete
*
[39] Fix | Delete
* @var array
[40] Fix | Delete
*/
[41] Fix | Delete
protected $_defaultConfig = [
[42] Fix | Delete
'duration' => 3600,
[43] Fix | Delete
'groups' => [],
[44] Fix | Delete
'prefix' => 'cake_',
[45] Fix | Delete
'probability' => 100,
[46] Fix | Delete
'warnOnWriteFailures' => true,
[47] Fix | Delete
];
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Contains the compiled string with all groups
[51] Fix | Delete
* prefixes to be prepended to every key in this cache engine
[52] Fix | Delete
*
[53] Fix | Delete
* @var string
[54] Fix | Delete
*/
[55] Fix | Delete
protected $_groupPrefix;
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Initialize the cache engine
[59] Fix | Delete
*
[60] Fix | Delete
* Called automatically by the cache frontend. Merge the runtime config with the defaults
[61] Fix | Delete
* before use.
[62] Fix | Delete
*
[63] Fix | Delete
* @param array $config Associative array of parameters for the engine
[64] Fix | Delete
* @return bool True if the engine has been successfully initialized, false if not
[65] Fix | Delete
*/
[66] Fix | Delete
public function init(array $config = [])
[67] Fix | Delete
{
[68] Fix | Delete
$this->setConfig($config);
[69] Fix | Delete
[70] Fix | Delete
if (!empty($this->_config['groups'])) {
[71] Fix | Delete
sort($this->_config['groups']);
[72] Fix | Delete
$this->_groupPrefix = str_repeat('%s_', count($this->_config['groups']));
[73] Fix | Delete
}
[74] Fix | Delete
if (!is_numeric($this->_config['duration'])) {
[75] Fix | Delete
$this->_config['duration'] = strtotime($this->_config['duration']) - time();
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
return true;
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Garbage collection
[83] Fix | Delete
*
[84] Fix | Delete
* Permanently remove all expired and deleted data
[85] Fix | Delete
*
[86] Fix | Delete
* @param int|null $expires [optional] An expires timestamp, invalidating all data before.
[87] Fix | Delete
* @return void
[88] Fix | Delete
*/
[89] Fix | Delete
public function gc($expires = null)
[90] Fix | Delete
{
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Write value for a key into cache
[95] Fix | Delete
*
[96] Fix | Delete
* @param string $key Identifier for the data
[97] Fix | Delete
* @param mixed $value Data to be cached
[98] Fix | Delete
* @return bool True if the data was successfully cached, false on failure
[99] Fix | Delete
*/
[100] Fix | Delete
abstract public function write($key, $value);
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Write data for many keys into cache
[104] Fix | Delete
*
[105] Fix | Delete
* @param array $data An array of data to be stored in the cache
[106] Fix | Delete
* @return array of bools for each key provided, true if the data was successfully cached, false on failure
[107] Fix | Delete
*/
[108] Fix | Delete
public function writeMany($data)
[109] Fix | Delete
{
[110] Fix | Delete
$return = [];
[111] Fix | Delete
foreach ($data as $key => $value) {
[112] Fix | Delete
$return[$key] = $this->write($key, $value);
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
return $return;
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* Read a key from the cache
[120] Fix | Delete
*
[121] Fix | Delete
* @param string $key Identifier for the data
[122] 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
[123] Fix | Delete
*/
[124] Fix | Delete
abstract public function read($key);
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Read multiple keys from the cache
[128] Fix | Delete
*
[129] Fix | Delete
* @param array $keys An array of identifiers for the data
[130] Fix | Delete
* @return array For each cache key (given as the array key) the cache data associated or false if the data doesn't
[131] Fix | Delete
* exist, has expired, or if there was an error fetching it
[132] Fix | Delete
*/
[133] Fix | Delete
public function readMany($keys)
[134] Fix | Delete
{
[135] Fix | Delete
$return = [];
[136] Fix | Delete
foreach ($keys as $key) {
[137] Fix | Delete
$return[$key] = $this->read($key);
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
return $return;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* Increment a number under the key and return incremented value
[145] Fix | Delete
*
[146] Fix | Delete
* @param string $key Identifier for the data
[147] Fix | Delete
* @param int $offset How much to add
[148] Fix | Delete
* @return int|false New incremented value, false otherwise
[149] Fix | Delete
*/
[150] Fix | Delete
abstract public function increment($key, $offset = 1);
[151] Fix | Delete
[152] Fix | Delete
/**
[153] Fix | Delete
* Decrement a number under the key and return decremented value
[154] Fix | Delete
*
[155] Fix | Delete
* @param string $key Identifier for the data
[156] Fix | Delete
* @param int $offset How much to subtract
[157] Fix | Delete
* @return int|false New incremented value, false otherwise
[158] Fix | Delete
*/
[159] Fix | Delete
abstract public function decrement($key, $offset = 1);
[160] Fix | Delete
[161] Fix | Delete
/**
[162] Fix | Delete
* Delete a key from the cache
[163] Fix | Delete
*
[164] Fix | Delete
* @param string $key Identifier for the data
[165] Fix | Delete
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
[166] Fix | Delete
*/
[167] Fix | Delete
abstract public function delete($key);
[168] Fix | Delete
[169] Fix | Delete
/**
[170] Fix | Delete
* Delete all keys from the cache
[171] Fix | Delete
*
[172] Fix | Delete
* @param bool $check if true will check expiration, otherwise delete all
[173] Fix | Delete
* @return bool True if the cache was successfully cleared, false otherwise
[174] Fix | Delete
*/
[175] Fix | Delete
abstract public function clear($check);
[176] Fix | Delete
[177] Fix | Delete
/**
[178] Fix | Delete
* Deletes keys from the cache
[179] Fix | Delete
*
[180] Fix | Delete
* @param array $keys An array of identifiers for the data
[181] Fix | Delete
* @return array For each provided cache key (given back as the array key) true if the value was successfully deleted,
[182] Fix | Delete
* false if it didn't exist or couldn't be removed
[183] Fix | Delete
*/
[184] Fix | Delete
public function deleteMany($keys)
[185] Fix | Delete
{
[186] Fix | Delete
$return = [];
[187] Fix | Delete
foreach ($keys as $key) {
[188] Fix | Delete
$return[$key] = $this->delete($key);
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
return $return;
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
/**
[195] Fix | Delete
* Add a key to the cache if it does not already exist.
[196] Fix | Delete
*
[197] Fix | Delete
* Defaults to a non-atomic implementation. Subclasses should
[198] Fix | Delete
* prefer atomic implementations.
[199] Fix | Delete
*
[200] Fix | Delete
* @param string $key Identifier for the data.
[201] Fix | Delete
* @param mixed $value Data to be cached.
[202] Fix | Delete
* @return bool True if the data was successfully cached, false on failure.
[203] Fix | Delete
*/
[204] Fix | Delete
public function add($key, $value)
[205] Fix | Delete
{
[206] Fix | Delete
$cachedValue = $this->read($key);
[207] Fix | Delete
if ($cachedValue === false) {
[208] Fix | Delete
return $this->write($key, $value);
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
return false;
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
/**
[215] Fix | Delete
* Clears all values belonging to a group. Is up to the implementing engine
[216] Fix | Delete
* to decide whether actually delete the keys or just simulate it to achieve
[217] Fix | Delete
* the same result.
[218] Fix | Delete
*
[219] Fix | Delete
* @param string $group name of the group to be cleared
[220] Fix | Delete
* @return bool
[221] Fix | Delete
*/
[222] Fix | Delete
public function clearGroup($group)
[223] Fix | Delete
{
[224] Fix | Delete
return false;
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
/**
[228] Fix | Delete
* Does whatever initialization for each group is required
[229] Fix | Delete
* and returns the `group value` for each of them, this is
[230] Fix | Delete
* the token representing each group in the cache key
[231] Fix | Delete
*
[232] Fix | Delete
* @return string[]
[233] Fix | Delete
*/
[234] Fix | Delete
public function groups()
[235] Fix | Delete
{
[236] Fix | Delete
return $this->_config['groups'];
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
/**
[240] Fix | Delete
* Generates a safe key for use with cache engine storage engines.
[241] Fix | Delete
*
[242] Fix | Delete
* @param string $key the key passed over
[243] Fix | Delete
* @return string|false string key or false
[244] Fix | Delete
*/
[245] Fix | Delete
public function key($key)
[246] Fix | Delete
{
[247] Fix | Delete
if (!$key) {
[248] Fix | Delete
return false;
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
$prefix = '';
[252] Fix | Delete
if ($this->_groupPrefix) {
[253] Fix | Delete
$prefix = md5(implode('_', $this->groups()));
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
$key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace([DIRECTORY_SEPARATOR, '/', '.'], '_', (string)$key))));
[257] Fix | Delete
[258] Fix | Delete
return $prefix . $key;
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
/**
[262] Fix | Delete
* Generates a safe key, taking account of the configured key prefix
[263] Fix | Delete
*
[264] Fix | Delete
* @param string $key the key passed over
[265] Fix | Delete
* @return string Key
[266] Fix | Delete
* @throws \InvalidArgumentException If key's value is empty
[267] Fix | Delete
*/
[268] Fix | Delete
protected function _key($key)
[269] Fix | Delete
{
[270] Fix | Delete
$key = $this->key($key);
[271] Fix | Delete
if ($key === false) {
[272] Fix | Delete
throw new InvalidArgumentException('An empty value is not valid as a cache key');
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
return $this->_config['prefix'] . $key;
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
/**
[279] Fix | Delete
* Cache Engines may trigger warnings if they encounter failures during operation,
[280] Fix | Delete
* if option warnOnWriteFailures is set to true.
[281] Fix | Delete
*
[282] Fix | Delete
* @param string $message The warning message.
[283] Fix | Delete
* @return void
[284] Fix | Delete
*/
[285] Fix | Delete
protected function warning($message)
[286] Fix | Delete
{
[287] Fix | Delete
if ($this->getConfig('warnOnWriteFailures') !== true) {
[288] Fix | Delete
return;
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
triggerWarning($message);
[292] Fix | Delete
}
[293] Fix | Delete
}
[294] Fix | Delete
[295] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function