Edit File by line
/home/zeestwma/richards.../wp-inclu.../SimplePi.../src/Cache
File: Psr16.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
[2] Fix | Delete
// SPDX-License-Identifier: BSD-3-Clause
[3] Fix | Delete
[4] Fix | Delete
declare(strict_types=1);
[5] Fix | Delete
[6] Fix | Delete
namespace SimplePie\Cache;
[7] Fix | Delete
[8] Fix | Delete
use Psr\SimpleCache\CacheInterface;
[9] Fix | Delete
use Psr\SimpleCache\InvalidArgumentException;
[10] Fix | Delete
use Throwable;
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Caches data into a PSR-16 cache implementation
[14] Fix | Delete
*
[15] Fix | Delete
* @internal
[16] Fix | Delete
*/
[17] Fix | Delete
final class Psr16 implements DataCache
[18] Fix | Delete
{
[19] Fix | Delete
/**
[20] Fix | Delete
* PSR-16 cache implementation
[21] Fix | Delete
*
[22] Fix | Delete
* @var CacheInterface
[23] Fix | Delete
*/
[24] Fix | Delete
private $cache;
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* PSR-16 cache implementation
[28] Fix | Delete
*
[29] Fix | Delete
* @param CacheInterface $cache
[30] Fix | Delete
*/
[31] Fix | Delete
public function __construct(CacheInterface $cache)
[32] Fix | Delete
{
[33] Fix | Delete
$this->cache = $cache;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Fetches a value from the cache.
[38] Fix | Delete
*
[39] Fix | Delete
* Equivalent to \Psr\SimpleCache\CacheInterface::get()
[40] Fix | Delete
* <code>
[41] Fix | Delete
* public function get(string $key, mixed $default = null): mixed;
[42] Fix | Delete
* </code>
[43] Fix | Delete
*
[44] Fix | Delete
* @param string $key The unique key of this item in the cache.
[45] Fix | Delete
* @param mixed $default Default value to return if the key does not exist.
[46] Fix | Delete
*
[47] Fix | Delete
* @return array|mixed The value of the item from the cache, or $default in case of cache miss.
[48] Fix | Delete
*
[49] Fix | Delete
* @throws InvalidArgumentException&Throwable
[50] Fix | Delete
* MUST be thrown if the $key string is not a legal value.
[51] Fix | Delete
*/
[52] Fix | Delete
public function get_data(string $key, $default = null)
[53] Fix | Delete
{
[54] Fix | Delete
$data = $this->cache->get($key, $default);
[55] Fix | Delete
[56] Fix | Delete
if (!is_array($data) || $data === $default) {
[57] Fix | Delete
return $default;
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
return $data;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
[65] Fix | Delete
*
[66] Fix | Delete
* Equivalent to \Psr\SimpleCache\CacheInterface::set()
[67] Fix | Delete
* <code>
[68] Fix | Delete
* public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool;
[69] Fix | Delete
* </code>
[70] Fix | Delete
*
[71] Fix | Delete
* @param string $key The key of the item to store.
[72] Fix | Delete
* @param array<mixed> $value The value of the item to store, must be serializable.
[73] Fix | Delete
* @param null|int $ttl Optional. The TTL value of this item. If no value is sent and
[74] Fix | Delete
* the driver supports TTL then the library may set a default value
[75] Fix | Delete
* for it or let the driver take care of that.
[76] Fix | Delete
*
[77] Fix | Delete
* @return bool True on success and false on failure.
[78] Fix | Delete
*
[79] Fix | Delete
* @throws InvalidArgumentException&Throwable
[80] Fix | Delete
* MUST be thrown if the $key string is not a legal value.
[81] Fix | Delete
*/
[82] Fix | Delete
public function set_data(string $key, array $value, ?int $ttl = null): bool
[83] Fix | Delete
{
[84] Fix | Delete
return $this->cache->set($key, $value, $ttl);
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Delete an item from the cache by its unique key.
[89] Fix | Delete
*
[90] Fix | Delete
* Equivalent to \Psr\SimpleCache\CacheInterface::delete()
[91] Fix | Delete
* <code>
[92] Fix | Delete
* public function delete(string $key): bool;
[93] Fix | Delete
* </code>
[94] Fix | Delete
*
[95] Fix | Delete
* @param string $key The unique cache key of the item to delete.
[96] Fix | Delete
*
[97] Fix | Delete
* @return bool True if the item was successfully removed. False if there was an error.
[98] Fix | Delete
*
[99] Fix | Delete
* @throws InvalidArgumentException&Throwable
[100] Fix | Delete
* MUST be thrown if the $key string is not a legal value.
[101] Fix | Delete
*/
[102] Fix | Delete
public function delete_data(string $key): bool
[103] Fix | Delete
{
[104] Fix | Delete
return $this->cache->delete($key);
[105] Fix | Delete
}
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function