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/Engine
File: ApcuEngine.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 3.5.4
[11] Fix | Delete
* @license https://opensource.org/licenses/mit-license.php MIT License
[12] Fix | Delete
*/
[13] Fix | Delete
namespace Cake\Cache\Engine;
[14] Fix | Delete
[15] Fix | Delete
use APCUIterator;
[16] Fix | Delete
use Cake\Cache\CacheEngine;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* APCu storage engine for cache
[20] Fix | Delete
*/
[21] Fix | Delete
class ApcuEngine extends CacheEngine
[22] Fix | Delete
{
[23] Fix | Delete
/**
[24] Fix | Delete
* Contains the compiled group names
[25] Fix | Delete
* (prefixed with the global configuration prefix)
[26] Fix | Delete
*
[27] Fix | Delete
* @var string[]
[28] Fix | Delete
*/
[29] Fix | Delete
protected $_compiledGroupNames = [];
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Initialize the Cache Engine
[33] Fix | Delete
*
[34] Fix | Delete
* Called automatically by the cache frontend
[35] Fix | Delete
*
[36] Fix | Delete
* @param array $config array of setting for the engine
[37] Fix | Delete
* @return bool True if the engine has been successfully initialized, false if not
[38] Fix | Delete
*/
[39] Fix | Delete
public function init(array $config = [])
[40] Fix | Delete
{
[41] Fix | Delete
if (!extension_loaded('apcu')) {
[42] Fix | Delete
return false;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
return parent::init($config);
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Write data for key into cache
[50] Fix | Delete
*
[51] Fix | Delete
* @param string $key Identifier for the data
[52] Fix | Delete
* @param mixed $value Data to be cached
[53] Fix | Delete
* @return bool True if the data was successfully cached, false on failure
[54] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-store.php
[55] Fix | Delete
*/
[56] Fix | Delete
public function write($key, $value)
[57] Fix | Delete
{
[58] Fix | Delete
$key = $this->_key($key);
[59] Fix | Delete
$duration = $this->_config['duration'];
[60] Fix | Delete
[61] Fix | Delete
return apcu_store($key, $value, $duration);
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Read a key from the cache
[66] Fix | Delete
*
[67] Fix | Delete
* @param string $key Identifier for the data
[68] Fix | Delete
* @return mixed The cached data, or false if the data doesn't exist,
[69] Fix | Delete
* has expired, or if there was an error fetching it
[70] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-fetch.php
[71] Fix | Delete
*/
[72] Fix | Delete
public function read($key)
[73] Fix | Delete
{
[74] Fix | Delete
$key = $this->_key($key);
[75] Fix | Delete
[76] Fix | Delete
return apcu_fetch($key);
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* Increments the value of an integer cached key
[81] Fix | Delete
*
[82] Fix | Delete
* @param string $key Identifier for the data
[83] Fix | Delete
* @param int $offset How much to increment
[84] Fix | Delete
* @return int|false New incremented value, false otherwise
[85] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-inc.php
[86] Fix | Delete
*/
[87] Fix | Delete
public function increment($key, $offset = 1)
[88] Fix | Delete
{
[89] Fix | Delete
$key = $this->_key($key);
[90] Fix | Delete
[91] Fix | Delete
return apcu_inc($key, $offset);
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Decrements the value of an integer cached key
[96] Fix | Delete
*
[97] Fix | Delete
* @param string $key Identifier for the data
[98] Fix | Delete
* @param int $offset How much to subtract
[99] Fix | Delete
* @return int|false New decremented value, false otherwise
[100] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-dec.php
[101] Fix | Delete
*/
[102] Fix | Delete
public function decrement($key, $offset = 1)
[103] Fix | Delete
{
[104] Fix | Delete
$key = $this->_key($key);
[105] Fix | Delete
[106] Fix | Delete
return apcu_dec($key, $offset);
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
/**
[110] Fix | Delete
* Delete a key from the cache
[111] Fix | Delete
*
[112] Fix | Delete
* @param string $key Identifier for the data
[113] Fix | Delete
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
[114] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-delete.php
[115] Fix | Delete
*/
[116] Fix | Delete
public function delete($key)
[117] Fix | Delete
{
[118] Fix | Delete
$key = $this->_key($key);
[119] Fix | Delete
[120] Fix | Delete
return apcu_delete($key);
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* Delete all keys from the cache. This will clear every cache config using APC.
[125] Fix | Delete
*
[126] Fix | Delete
* @param bool $check If true, nothing will be cleared, as entries are removed
[127] Fix | Delete
* from APC as they expired. This flag is really only used by FileEngine.
[128] Fix | Delete
* @return bool True Returns true.
[129] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-cache-info.php
[130] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-delete.php
[131] Fix | Delete
*/
[132] Fix | Delete
public function clear($check)
[133] Fix | Delete
{
[134] Fix | Delete
if ($check) {
[135] Fix | Delete
return true;
[136] Fix | Delete
}
[137] Fix | Delete
if (class_exists(APCUIterator::class, false)) {
[138] Fix | Delete
$iterator = new APCUIterator(
[139] Fix | Delete
'/^' . preg_quote($this->_config['prefix'], '/') . '/',
[140] Fix | Delete
APC_ITER_NONE
[141] Fix | Delete
);
[142] Fix | Delete
apcu_delete($iterator);
[143] Fix | Delete
[144] Fix | Delete
return true;
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
$cache = apcu_cache_info(); // Raises warning by itself already
[148] Fix | Delete
foreach ($cache['cache_list'] as $key) {
[149] Fix | Delete
if (strpos($key['info'], $this->_config['prefix']) === 0) {
[150] Fix | Delete
apcu_delete($key['info']);
[151] Fix | Delete
}
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
return true;
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* Write data for key into cache if it doesn't exist already.
[159] Fix | Delete
* If it already exists, it fails and returns false.
[160] Fix | Delete
*
[161] Fix | Delete
* @param string $key Identifier for the data.
[162] Fix | Delete
* @param mixed $value Data to be cached.
[163] Fix | Delete
* @return bool True if the data was successfully cached, false on failure.
[164] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-add.php
[165] Fix | Delete
*/
[166] Fix | Delete
public function add($key, $value)
[167] Fix | Delete
{
[168] Fix | Delete
$key = $this->_key($key);
[169] Fix | Delete
$duration = $this->_config['duration'];
[170] Fix | Delete
[171] Fix | Delete
return apcu_add($key, $value, $duration);
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
/**
[175] Fix | Delete
* Returns the `group value` for each of the configured groups
[176] Fix | Delete
* If the group initial value was not found, then it initializes
[177] Fix | Delete
* the group accordingly.
[178] Fix | Delete
*
[179] Fix | Delete
* @return string[]
[180] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-fetch.php
[181] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-store.php
[182] Fix | Delete
*/
[183] Fix | Delete
public function groups()
[184] Fix | Delete
{
[185] Fix | Delete
if (empty($this->_compiledGroupNames)) {
[186] Fix | Delete
foreach ($this->_config['groups'] as $group) {
[187] Fix | Delete
$this->_compiledGroupNames[] = $this->_config['prefix'] . $group;
[188] Fix | Delete
}
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
$success = false;
[192] Fix | Delete
$groups = apcu_fetch($this->_compiledGroupNames, $success);
[193] Fix | Delete
if ($success && count($groups) !== count($this->_config['groups'])) {
[194] Fix | Delete
foreach ($this->_compiledGroupNames as $group) {
[195] Fix | Delete
if (!isset($groups[$group])) {
[196] Fix | Delete
$value = 1;
[197] Fix | Delete
if (apcu_store($group, $value) === false) {
[198] Fix | Delete
$this->warning(
[199] Fix | Delete
sprintf('Failed to store key "%s" with value "%s" into APCu cache.', $group, $value)
[200] Fix | Delete
);
[201] Fix | Delete
}
[202] Fix | Delete
$groups[$group] = $value;
[203] Fix | Delete
}
[204] Fix | Delete
}
[205] Fix | Delete
ksort($groups);
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
$result = [];
[209] Fix | Delete
$groups = array_values($groups);
[210] Fix | Delete
foreach ($this->_config['groups'] as $i => $group) {
[211] Fix | Delete
$result[] = $group . $groups[$i];
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
return $result;
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
/**
[218] Fix | Delete
* Increments the group value to simulate deletion of all keys under a group
[219] Fix | Delete
* old values will remain in storage until they expire.
[220] Fix | Delete
*
[221] Fix | Delete
* @param string $group The group to clear.
[222] Fix | Delete
* @return bool success
[223] Fix | Delete
* @link https://secure.php.net/manual/en/function.apcu-inc.php
[224] Fix | Delete
*/
[225] Fix | Delete
public function clearGroup($group)
[226] Fix | Delete
{
[227] Fix | Delete
$success = false;
[228] Fix | Delete
apcu_inc($this->_config['prefix'] . $group, 1, $success);
[229] Fix | Delete
[230] Fix | Delete
return $success;
[231] Fix | Delete
}
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function