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: SimpleCacheEngine.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
[14] Fix | Delete
namespace Cake\Cache;
[15] Fix | Delete
[16] Fix | Delete
use Cake\Cache\CacheEngineInterface;
[17] Fix | Delete
use Psr\SimpleCache\CacheInterface;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Wrapper for Cake engines that allow them to support
[21] Fix | Delete
* the PSR16 Simple Cache Interface
[22] Fix | Delete
*
[23] Fix | Delete
* @since 3.7.0
[24] Fix | Delete
* @link https://www.php-fig.org/psr/psr-16/
[25] Fix | Delete
*/
[26] Fix | Delete
class SimpleCacheEngine implements CacheInterface, CacheEngineInterface
[27] Fix | Delete
{
[28] Fix | Delete
/**
[29] Fix | Delete
* The wrapped cache engine object.
[30] Fix | Delete
*
[31] Fix | Delete
* @var \Cake\Cache\CacheEngine
[32] Fix | Delete
*/
[33] Fix | Delete
protected $innerEngine;
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Constructor
[37] Fix | Delete
*
[38] Fix | Delete
* @param \Cake\Cache\CacheEngine $innerEngine The decorated engine.
[39] Fix | Delete
*/
[40] Fix | Delete
public function __construct(CacheEngine $innerEngine)
[41] Fix | Delete
{
[42] Fix | Delete
$this->innerEngine = $innerEngine;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Ensure the validity of the given cache key.
[47] Fix | Delete
*
[48] Fix | Delete
* @param string $key Key to check.
[49] Fix | Delete
* @return void
[50] Fix | Delete
* @throws \Cake\Cache\InvalidArgumentException When the key is not valid.
[51] Fix | Delete
*/
[52] Fix | Delete
protected function ensureValidKey($key)
[53] Fix | Delete
{
[54] Fix | Delete
if (!is_string($key) || strlen($key) === 0) {
[55] Fix | Delete
throw new InvalidArgumentException('A cache key must be a non-empty string.');
[56] Fix | Delete
}
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Ensure the validity of the given cache keys.
[61] Fix | Delete
*
[62] Fix | Delete
* @param mixed $keys The keys to check.
[63] Fix | Delete
* @return void
[64] Fix | Delete
* @throws \Cake\Cache\InvalidArgumentException When the keys are not valid.
[65] Fix | Delete
*/
[66] Fix | Delete
protected function ensureValidKeys($keys)
[67] Fix | Delete
{
[68] Fix | Delete
if (!is_array($keys) && !($keys instanceof \Traversable)) {
[69] Fix | Delete
throw new InvalidArgumentException('A cache key set must be either an array or a Traversable.');
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
foreach ($keys as $key) {
[73] Fix | Delete
$this->ensureValidKey($key);
[74] Fix | Delete
}
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Fetches the value for a given key from the cache.
[79] Fix | Delete
*
[80] Fix | Delete
* @param string $key The unique key of this item in the cache.
[81] Fix | Delete
* @param mixed $default Default value to return if the key does not exist.
[82] Fix | Delete
* @return mixed The value of the item from the cache, or $default in case of cache miss.
[83] Fix | Delete
* @throws \Cake\Cache\InvalidArgumentException If the $key string is not a legal value.
[84] Fix | Delete
*/
[85] Fix | Delete
public function get($key, $default = null)
[86] Fix | Delete
{
[87] Fix | Delete
$this->ensureValidKey($key);
[88] Fix | Delete
$result = $this->innerEngine->read($key);
[89] Fix | Delete
if ($result === false) {
[90] Fix | Delete
return $default;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
return $result;
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
/**
[97] Fix | Delete
* Persists data in the cache, uniquely referenced by the given key with an optional expiration TTL time.
[98] Fix | Delete
*
[99] Fix | Delete
* @param string $key The key of the item to store.
[100] Fix | Delete
* @param mixed $value The value of the item to store, must be serializable.
[101] Fix | Delete
* @param \DateInterval|int|null $ttl Optional. The TTL value of this item. If no value is sent and
[102] Fix | Delete
* the driver supports TTL then the library may set a default value
[103] Fix | Delete
* for it or let the driver take care of that.
[104] Fix | Delete
* @return bool True on success and false on failure.
[105] Fix | Delete
* @throws \Cake\Cache\InvalidArgumentException
[106] Fix | Delete
* MUST be thrown if the $key string is not a legal value.
[107] Fix | Delete
*/
[108] Fix | Delete
public function set($key, $value, $ttl = null)
[109] Fix | Delete
{
[110] Fix | Delete
$this->ensureValidKey($key);
[111] Fix | Delete
if ($ttl !== null) {
[112] Fix | Delete
$restore = $this->innerEngine->getConfig('duration');
[113] Fix | Delete
$this->innerEngine->setConfig('duration', $ttl);
[114] Fix | Delete
}
[115] Fix | Delete
try {
[116] Fix | Delete
$result = $this->innerEngine->write($key, $value);
[117] Fix | Delete
[118] Fix | Delete
return (bool)$result;
[119] Fix | Delete
} finally {
[120] Fix | Delete
if (isset($restore)) {
[121] Fix | Delete
$this->innerEngine->setConfig('duration', $restore);
[122] Fix | Delete
}
[123] Fix | Delete
}
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Delete an item from the cache by its unique key.
[128] Fix | Delete
*
[129] Fix | Delete
* @param string $key The unique cache key of the item to delete.
[130] Fix | Delete
* @return bool True if the item was successfully removed. False if there was an error.
[131] Fix | Delete
* @throws \Cake\Cache\InvalidArgumentException If the $key string is not a legal value.
[132] Fix | Delete
*/
[133] Fix | Delete
public function delete($key)
[134] Fix | Delete
{
[135] Fix | Delete
$this->ensureValidKey($key);
[136] Fix | Delete
[137] Fix | Delete
return $this->innerEngine->delete($key);
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
/**
[141] Fix | Delete
* Wipes clean the entire cache's keys.
[142] Fix | Delete
*
[143] Fix | Delete
* @return bool True on success and false on failure.
[144] Fix | Delete
*/
[145] Fix | Delete
public function clear()
[146] Fix | Delete
{
[147] Fix | Delete
return $this->innerEngine->clear(false);
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* Obtains multiple cache items by their unique keys.
[152] Fix | Delete
*
[153] Fix | Delete
* @param iterable $keys A list of keys that can obtained in a single operation.
[154] Fix | Delete
* @param mixed $default Default value to return for keys that do not exist.
[155] Fix | Delete
* @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
[156] Fix | Delete
* @throws \Cake\Cache\InvalidArgumentException If $keys is neither an array nor a Traversable,
[157] Fix | Delete
* or if any of the $keys are not a legal value.
[158] Fix | Delete
*/
[159] Fix | Delete
public function getMultiple($keys, $default = null)
[160] Fix | Delete
{
[161] Fix | Delete
$this->ensureValidKeys($keys);
[162] Fix | Delete
[163] Fix | Delete
$results = $this->innerEngine->readMany($keys);
[164] Fix | Delete
foreach ($results as $key => $value) {
[165] Fix | Delete
if ($value === false) {
[166] Fix | Delete
$results[$key] = $default;
[167] Fix | Delete
}
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
return $results;
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
/**
[174] Fix | Delete
* Persists a set of key => value pairs in the cache, with an optional TTL.
[175] Fix | Delete
*
[176] Fix | Delete
* @param iterable $values A list of key => value pairs for a multiple-set operation.
[177] Fix | Delete
* @param \DateInterval|int|null $ttl Optional. The TTL value of this item. If no value is sent and
[178] Fix | Delete
* the driver supports TTL then the library may set a default value
[179] Fix | Delete
* for it or let the driver take care of that.
[180] Fix | Delete
* @return bool True on success and false on failure.
[181] Fix | Delete
* @throws \Cake\Cache\InvalidArgumentException If $values is neither an array nor a Traversable,
[182] Fix | Delete
* or if any of the $values are not a legal value.
[183] Fix | Delete
*/
[184] Fix | Delete
public function setMultiple($values, $ttl = null)
[185] Fix | Delete
{
[186] Fix | Delete
$this->ensureValidKeys(array_keys($values));
[187] Fix | Delete
[188] Fix | Delete
if ($ttl !== null) {
[189] Fix | Delete
$restore = $this->innerEngine->getConfig('duration');
[190] Fix | Delete
$this->innerEngine->setConfig('duration', $ttl);
[191] Fix | Delete
}
[192] Fix | Delete
try {
[193] Fix | Delete
$result = $this->innerEngine->writeMany($values);
[194] Fix | Delete
foreach ($result as $key => $success) {
[195] Fix | Delete
if ($success === false) {
[196] Fix | Delete
return false;
[197] Fix | Delete
}
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
return true;
[201] Fix | Delete
} finally {
[202] Fix | Delete
if (isset($restore)) {
[203] Fix | Delete
$this->innerEngine->setConfig('duration', $restore);
[204] Fix | Delete
}
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
return false;
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
/**
[211] Fix | Delete
* Deletes multiple cache items in a single operation.
[212] Fix | Delete
*
[213] Fix | Delete
* @param iterable $keys A list of string-based keys to be deleted.
[214] Fix | Delete
* @return bool True if the items were successfully removed. False if there was an error.
[215] Fix | Delete
* @throws \Cake\Cache\InvalidArgumentException If $keys is neither an array nor a Traversable,
[216] Fix | Delete
* or if any of the $keys are not a legal value.
[217] Fix | Delete
*/
[218] Fix | Delete
public function deleteMultiple($keys)
[219] Fix | Delete
{
[220] Fix | Delete
$this->ensureValidKeys($keys);
[221] Fix | Delete
[222] Fix | Delete
$result = $this->innerEngine->deleteMany($keys);
[223] Fix | Delete
foreach ($result as $key => $success) {
[224] Fix | Delete
if ($success === false) {
[225] Fix | Delete
return false;
[226] Fix | Delete
}
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
return true;
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
/**
[233] Fix | Delete
* Determines whether an item is present in the cache.
[234] Fix | Delete
*
[235] Fix | Delete
* NOTE: It is recommended that has() is only to be used for cache warming type purposes
[236] Fix | Delete
* and not to be used within your live applications operations for get/set, as this method
[237] Fix | Delete
* is subject to a race condition where your has() will return true and immediately after,
[238] Fix | Delete
* another script can remove it making the state of your app out of date.
[239] Fix | Delete
*
[240] Fix | Delete
* @param string $key The cache item key.
[241] Fix | Delete
* @return bool
[242] Fix | Delete
* @throws \Cake\Cache\InvalidArgumentException If the $key string is not a legal value.
[243] Fix | Delete
*/
[244] Fix | Delete
public function has($key)
[245] Fix | Delete
{
[246] Fix | Delete
return $this->get($key) !== null;
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
/**
[250] Fix | Delete
* {@inheritDoc}
[251] Fix | Delete
*/
[252] Fix | Delete
public function add($key, $value)
[253] Fix | Delete
{
[254] Fix | Delete
return $this->innerEngine->add($key, $value);
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
/**
[258] Fix | Delete
* {@inheritDoc}
[259] Fix | Delete
*/
[260] Fix | Delete
public function increment($key, $offset = 1)
[261] Fix | Delete
{
[262] Fix | Delete
return $this->innerEngine->increment($key, $offset);
[263] Fix | Delete
}
[264] Fix | Delete
[265] Fix | Delete
/**
[266] Fix | Delete
* {@inheritDoc}
[267] Fix | Delete
*/
[268] Fix | Delete
public function decrement($key, $offset = 1)
[269] Fix | Delete
{
[270] Fix | Delete
return $this->innerEngine->decrement($key, $offset);
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
/**
[274] Fix | Delete
* {@inheritDoc}
[275] Fix | Delete
*/
[276] Fix | Delete
public function clearGroup($group)
[277] Fix | Delete
{
[278] Fix | Delete
return $this->innerEngine->clearGroup($group);
[279] Fix | Delete
}
[280] Fix | Delete
}
[281] Fix | Delete
[282] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function