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: ArrayEngine.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.7.0
[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 Cake\Cache\CacheEngine;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Array storage engine for cache.
[19] Fix | Delete
*
[20] Fix | Delete
* Not actually a persistent cache engine. All data is only
[21] Fix | Delete
* stored in memory for the duration of a single process. While not
[22] Fix | Delete
* useful in production settings this engine can be useful in tests
[23] Fix | Delete
* or console tools where you don't want the overhead of interacting
[24] Fix | Delete
* with a cache servers, but want the work saving properties a cache
[25] Fix | Delete
* provides.
[26] Fix | Delete
*/
[27] Fix | Delete
class ArrayEngine extends CacheEngine
[28] Fix | Delete
{
[29] Fix | Delete
/**
[30] Fix | Delete
* Cached data.
[31] Fix | Delete
*
[32] Fix | Delete
* Structured as [key => [exp => expiration, val => value]]
[33] Fix | Delete
*
[34] Fix | Delete
* @var array
[35] Fix | Delete
*/
[36] Fix | Delete
protected $data = [];
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Write data for key into cache
[40] Fix | Delete
*
[41] Fix | Delete
* @param string $key Identifier for the data
[42] Fix | Delete
* @param mixed $value Data to be cached
[43] Fix | Delete
* @return bool True if the data was successfully cached, false on failure
[44] Fix | Delete
*/
[45] Fix | Delete
public function write($key, $value)
[46] Fix | Delete
{
[47] Fix | Delete
$key = $this->_key($key);
[48] Fix | Delete
$expires = time() + $this->_config['duration'];
[49] Fix | Delete
$this->data[$key] = ['exp' => $expires, 'val' => $value];
[50] Fix | Delete
[51] Fix | Delete
return true;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Read a key from the cache
[56] Fix | Delete
*
[57] Fix | Delete
* @param string $key Identifier for the data
[58] Fix | Delete
* @return mixed The cached data, or false if the data doesn't exist,
[59] Fix | Delete
* has expired, or if there was an error fetching it
[60] Fix | Delete
*/
[61] Fix | Delete
public function read($key)
[62] Fix | Delete
{
[63] Fix | Delete
$key = $this->_key($key);
[64] Fix | Delete
if (!isset($this->data[$key])) {
[65] Fix | Delete
return false;
[66] Fix | Delete
}
[67] Fix | Delete
$data = $this->data[$key];
[68] Fix | Delete
[69] Fix | Delete
// Check expiration
[70] Fix | Delete
$now = time();
[71] Fix | Delete
if ($data['exp'] <= $now) {
[72] Fix | Delete
unset($this->data[$key]);
[73] Fix | Delete
[74] Fix | Delete
return false;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
return $data['val'];
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Increments the value of an integer cached key
[82] Fix | Delete
*
[83] Fix | Delete
* @param string $key Identifier for the data
[84] Fix | Delete
* @param int $offset How much to increment
[85] Fix | Delete
* @return int|false New incremented value, false otherwise
[86] Fix | Delete
*/
[87] Fix | Delete
public function increment($key, $offset = 1)
[88] Fix | Delete
{
[89] Fix | Delete
if (!$this->read($key)) {
[90] Fix | Delete
$this->write($key, 0);
[91] Fix | Delete
}
[92] Fix | Delete
$key = $this->_key($key);
[93] Fix | Delete
$this->data[$key]['val'] += $offset;
[94] Fix | Delete
[95] Fix | Delete
return $this->data[$key]['val'];
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Decrements the value of an integer cached key
[100] Fix | Delete
*
[101] Fix | Delete
* @param string $key Identifier for the data
[102] Fix | Delete
* @param int $offset How much to subtract
[103] Fix | Delete
* @return int|false New decremented value, false otherwise
[104] Fix | Delete
*/
[105] Fix | Delete
public function decrement($key, $offset = 1)
[106] Fix | Delete
{
[107] Fix | Delete
if (!$this->read($key)) {
[108] Fix | Delete
$this->write($key, 0);
[109] Fix | Delete
}
[110] Fix | Delete
$key = $this->_key($key);
[111] Fix | Delete
$this->data[$key]['val'] -= $offset;
[112] Fix | Delete
[113] Fix | Delete
return $this->data[$key]['val'];
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Delete a key from the cache
[118] Fix | Delete
*
[119] Fix | Delete
* @param string $key Identifier for the data
[120] Fix | Delete
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
[121] Fix | Delete
*/
[122] Fix | Delete
public function delete($key)
[123] Fix | Delete
{
[124] Fix | Delete
$key = $this->_key($key);
[125] Fix | Delete
unset($this->data[$key]);
[126] Fix | Delete
[127] Fix | Delete
return true;
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
/**
[131] Fix | Delete
* Delete all keys from the cache. This will clear every cache config using APC.
[132] Fix | Delete
*
[133] Fix | Delete
* @param bool $check Unused argument required by interface.
[134] Fix | Delete
* @return bool True Returns true.
[135] Fix | Delete
*/
[136] Fix | Delete
public function clear($check)
[137] Fix | Delete
{
[138] Fix | Delete
$this->data = [];
[139] Fix | Delete
[140] Fix | Delete
return true;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* Returns the `group value` for each of the configured groups
[145] Fix | Delete
* If the group initial value was not found, then it initializes
[146] Fix | Delete
* the group accordingly.
[147] Fix | Delete
*
[148] Fix | Delete
* @return string[]
[149] Fix | Delete
*/
[150] Fix | Delete
public function groups()
[151] Fix | Delete
{
[152] Fix | Delete
$result = [];
[153] Fix | Delete
foreach ($this->_config['groups'] as $group) {
[154] Fix | Delete
$key = $this->_config['prefix'] . $group;
[155] Fix | Delete
if (!isset($this->data[$key])) {
[156] Fix | Delete
$this->data[$key] = ['exp' => PHP_INT_MAX, 'val' => 1];
[157] Fix | Delete
}
[158] Fix | Delete
$value = $this->data[$key]['val'];
[159] Fix | Delete
$result[] = $group . $value;
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
return $result;
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
/**
[166] Fix | Delete
* Increments the group value to simulate deletion of all keys under a group
[167] Fix | Delete
* old values will remain in storage until they expire.
[168] Fix | Delete
*
[169] Fix | Delete
* @param string $group The group to clear.
[170] Fix | Delete
* @return bool success
[171] Fix | Delete
*/
[172] Fix | Delete
public function clearGroup($group)
[173] Fix | Delete
{
[174] Fix | Delete
$key = $this->_config['prefix'] . $group;
[175] Fix | Delete
if (isset($this->data[$key])) {
[176] Fix | Delete
$this->data[$key]['val'] += 1;
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
return true;
[180] Fix | Delete
}
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function