Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
19
vendor/doctrine/cache/LICENSE
vendored
Normal file
19
vendor/doctrine/cache/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2006-2015 Doctrine Project
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
13
vendor/doctrine/cache/README.md
vendored
Normal file
13
vendor/doctrine/cache/README.md
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Doctrine Cache
|
||||
|
||||
[](https://github.com/doctrine/cache/actions)
|
||||
[](https://codecov.io/gh/doctrine/cache/branch/1.10.x)
|
||||
|
||||
[](https://packagist.org/packages/doctrine/cache)
|
||||
[](https://packagist.org/packages/doctrine/cache)
|
||||
|
||||
Cache component extracted from the Doctrine Common project. [Documentation](https://www.doctrine-project.org/projects/doctrine-cache/en/current/index.html)
|
||||
|
||||
This library is deprecated and will no longer receive bug fixes from the
|
||||
Doctrine Project. Please use a different cache library, preferably PSR-6 or
|
||||
PSR-16 instead.
|
27
vendor/doctrine/cache/UPGRADE-1.11.md
vendored
Normal file
27
vendor/doctrine/cache/UPGRADE-1.11.md
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Upgrade to 1.11
|
||||
|
||||
doctrine/cache will no longer be maintained and all cache implementations have
|
||||
been marked as deprecated. These implementations will be removed in 2.0, which
|
||||
will only contain interfaces to provide a lightweight package for backward
|
||||
compatibility.
|
||||
|
||||
There are two new classes to use in the `Doctrine\Common\Cache\Psr6` namespace:
|
||||
* The `CacheAdapter` class allows using any Doctrine Cache as PSR-6 cache. This
|
||||
is useful to provide a forward compatibility layer in libraries that accept
|
||||
Doctrine cache implementations and switch to PSR-6.
|
||||
* The `DoctrineProvider` class allows using any PSR-6 cache as Doctrine cache.
|
||||
This implementation is designed for libraries that leak the cache and want to
|
||||
switch to allowing PSR-6 implementations. This class is design to be used
|
||||
during the transition phase of sunsetting doctrine/cache support.
|
||||
|
||||
A full example to setup a filesystem based PSR-6 cache with symfony/cache
|
||||
using the `DoctrineProvider` to convert back to Doctrine's `Cache` interface:
|
||||
|
||||
```php
|
||||
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
|
||||
$cachePool = new FilesystemAdapter();
|
||||
$cache = DoctrineProvider::wrap($cachePool);
|
||||
// $cache instanceof \Doctrine\Common\Cache\Cache
|
||||
```
|
16
vendor/doctrine/cache/UPGRADE-1.4.md
vendored
Normal file
16
vendor/doctrine/cache/UPGRADE-1.4.md
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Upgrade to 1.4
|
||||
|
||||
## Minor BC Break: `Doctrine\Common\Cache\FileCache#$extension` is now `private`.
|
||||
|
||||
If you need to override the value of `Doctrine\Common\Cache\FileCache#$extension`, then use the
|
||||
second parameter of `Doctrine\Common\Cache\FileCache#__construct()` instead of overriding
|
||||
the property in your own implementation.
|
||||
|
||||
## Minor BC Break: file based caches paths changed
|
||||
|
||||
`Doctrine\Common\Cache\FileCache`, `Doctrine\Common\Cache\PhpFileCache` and
|
||||
`Doctrine\Common\Cache\FilesystemCache` are using a different cache paths structure.
|
||||
|
||||
If you rely on warmed up caches for deployments, consider that caches generated
|
||||
with `doctrine/cache` `<1.4` are not compatible with the new directory structure,
|
||||
and will be ignored.
|
50
vendor/doctrine/cache/composer.json
vendored
Normal file
50
vendor/doctrine/cache/composer.json
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "doctrine/cache",
|
||||
"type": "library",
|
||||
"description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.",
|
||||
"keywords": [
|
||||
"php",
|
||||
"cache",
|
||||
"caching",
|
||||
"abstraction",
|
||||
"redis",
|
||||
"memcached",
|
||||
"couchdb",
|
||||
"xcache",
|
||||
"apcu"
|
||||
],
|
||||
"homepage": "https://www.doctrine-project.org/projects/cache.html",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
|
||||
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
|
||||
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"},
|
||||
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
|
||||
],
|
||||
"require": {
|
||||
"php": "~7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
|
||||
"doctrine/coding-standard": "^9",
|
||||
"psr/cache": "^1.0 || ^2.0 || ^3.0",
|
||||
"cache/integration-tests": "dev-master",
|
||||
"symfony/cache": "^4.4 || ^5.4 || ^6",
|
||||
"symfony/var-exporter": "^4.4 || ^5.4 || ^6"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": ">2.2,<2.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Doctrine\\Tests\\": "tests/Doctrine/Tests" }
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
90
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php
vendored
Normal file
90
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface Cache
|
||||
{
|
||||
public const STATS_HITS = 'hits';
|
||||
public const STATS_MISSES = 'misses';
|
||||
public const STATS_UPTIME = 'uptime';
|
||||
public const STATS_MEMORY_USAGE = 'memory_usage';
|
||||
public const STATS_MEMORY_AVAILABLE = 'memory_available';
|
||||
/**
|
||||
* Only for backward compatibility (may be removed in next major release)
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public const STATS_MEMORY_AVAILIABLE = 'memory_available';
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return mixed The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
public function fetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
public function contains($id);
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* If a cache entry with the given id already exists, its data will be replaced.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param mixed $data The cache entry/data.
|
||||
* @param int $lifeTime The lifetime in number of seconds for this cache entry.
|
||||
* If zero (the default), the entry never expires (although it may be deleted from the cache
|
||||
* to make place for other entries).
|
||||
*
|
||||
* @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
public function save($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
* Deleting a non-existing entry is considered successful.
|
||||
*/
|
||||
public function delete($id);
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* The server's statistics array has the following values:
|
||||
*
|
||||
* - <b>hits</b>
|
||||
* Number of keys that have been requested and found present.
|
||||
*
|
||||
* - <b>misses</b>
|
||||
* Number of items that have been requested and not found.
|
||||
*
|
||||
* - <b>uptime</b>
|
||||
* Time that the server is running.
|
||||
*
|
||||
* - <b>memory_usage</b>
|
||||
* Memory used by this server to store items.
|
||||
*
|
||||
* - <b>memory_available</b>
|
||||
* Memory allowed to use for storage.
|
||||
*
|
||||
* @return mixed[]|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
public function getStats();
|
||||
}
|
325
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php
vendored
Normal file
325
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php
vendored
Normal file
|
@ -0,0 +1,325 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use function array_combine;
|
||||
use function array_key_exists;
|
||||
use function array_map;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Base class for cache provider implementations.
|
||||
*/
|
||||
abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiOperationCache
|
||||
{
|
||||
public const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]';
|
||||
|
||||
/**
|
||||
* The namespace to prefix all cache ids with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $namespace = '';
|
||||
|
||||
/**
|
||||
* The namespace version.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private $namespaceVersion;
|
||||
|
||||
/**
|
||||
* Sets the namespace to prefix all cache ids with.
|
||||
*
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNamespace($namespace)
|
||||
{
|
||||
$this->namespace = (string) $namespace;
|
||||
$this->namespaceVersion = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the namespace that prefixes all cache ids.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->doFetch($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchMultiple(array $keys)
|
||||
{
|
||||
if (empty($keys)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// note: the array_combine() is in place to keep an association between our $keys and the $namespacedKeys
|
||||
$namespacedKeys = array_combine($keys, array_map([$this, 'getNamespacedId'], $keys));
|
||||
$items = $this->doFetchMultiple($namespacedKeys);
|
||||
$foundItems = [];
|
||||
|
||||
// no internal array function supports this sort of mapping: needs to be iterative
|
||||
// this filters and combines keys in one pass
|
||||
foreach ($namespacedKeys as $requestedKey => $namespacedKey) {
|
||||
if (! isset($items[$namespacedKey]) && ! array_key_exists($namespacedKey, $items)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$foundItems[$requestedKey] = $items[$namespacedKey];
|
||||
}
|
||||
|
||||
return $foundItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function saveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$namespacedKeysAndValues = [];
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
$namespacedKeysAndValues[$this->getNamespacedId($key)] = $value;
|
||||
}
|
||||
|
||||
return $this->doSaveMultiple($namespacedKeysAndValues, $lifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function contains($id)
|
||||
{
|
||||
return $this->doContains($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return $this->doSave($this->getNamespacedId($id), $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteMultiple(array $keys)
|
||||
{
|
||||
return $this->doDeleteMultiple(array_map([$this, 'getNamespacedId'], $keys));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return $this->doDelete($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStats()
|
||||
{
|
||||
return $this->doGetStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function flushAll()
|
||||
{
|
||||
return $this->doFlush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$namespaceVersion = $this->getNamespaceVersion() + 1;
|
||||
|
||||
if ($this->doSave($namespaceCacheKey, $namespaceVersion)) {
|
||||
$this->namespaceVersion = $namespaceVersion;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefixes the passed id with the configured namespace value.
|
||||
*
|
||||
* @param string $id The id to namespace.
|
||||
*
|
||||
* @return string The namespaced id.
|
||||
*/
|
||||
private function getNamespacedId(string $id): string
|
||||
{
|
||||
$namespaceVersion = $this->getNamespaceVersion();
|
||||
|
||||
return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace cache key.
|
||||
*/
|
||||
private function getNamespaceCacheKey(): string
|
||||
{
|
||||
return sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace version.
|
||||
*/
|
||||
private function getNamespaceVersion(): int
|
||||
{
|
||||
if ($this->namespaceVersion !== null) {
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$this->namespaceVersion = (int) $this->doFetch($namespaceCacheKey) ?: 1;
|
||||
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it.
|
||||
*
|
||||
* @param string[] $keys Array of keys to retrieve from cache
|
||||
*
|
||||
* @return mixed[] Array of values retrieved for the given keys.
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
$returnValues = [];
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$item = $this->doFetch($key);
|
||||
if ($item === false && ! $this->doContains($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$returnValues[$key] = $item;
|
||||
}
|
||||
|
||||
return $returnValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return mixed|false The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
abstract protected function doFetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doContains($id);
|
||||
|
||||
/**
|
||||
* Default implementation of doSaveMultiple. Each driver that supports multi-put should override it.
|
||||
*
|
||||
* @param mixed[] $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$success = true;
|
||||
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
if ($this->doSave($key, $value, $lifetime)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param string $data The cache entry/data.
|
||||
* @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this
|
||||
* cache entry (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doSave($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Default implementation of doDeleteMultiple. Each driver that supports multi-delete should override it.
|
||||
*
|
||||
* @param string[] $keys Array of keys to delete from cache
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't
|
||||
*/
|
||||
protected function doDeleteMultiple(array $keys)
|
||||
{
|
||||
$success = true;
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if ($this->doDelete($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doDelete($id);
|
||||
|
||||
/**
|
||||
* Flushes all cache entries.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doFlush();
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* @return mixed[]|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
abstract protected function doGetStats();
|
||||
}
|
21
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php
vendored
Normal file
21
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache that can be flushed.
|
||||
*
|
||||
* Intended to be used for partial clearing of a cache namespace. For a more
|
||||
* global "flushing", see {@see FlushableCache}.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface ClearableCache
|
||||
{
|
||||
/**
|
||||
* Deletes all cache entries in the current cache namespace.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
public function deleteAll();
|
||||
}
|
18
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php
vendored
Normal file
18
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache that can be flushed.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface FlushableCache
|
||||
{
|
||||
/**
|
||||
* Flushes all cache entries, globally.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
|
||||
*/
|
||||
public function flushAll();
|
||||
}
|
22
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiDeleteCache.php
vendored
Normal file
22
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiDeleteCache.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to put many items at once.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiDeleteCache
|
||||
{
|
||||
/**
|
||||
* Deletes several cache entries.
|
||||
*
|
||||
* @param string[] $keys Array of keys to delete from cache
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
public function deleteMultiple(array $keys);
|
||||
}
|
23
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php
vendored
Normal file
23
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to get many items at once.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiGetCache
|
||||
{
|
||||
/**
|
||||
* Returns an associative array of values for keys is found in cache.
|
||||
*
|
||||
* @param string[] $keys Array of keys to retrieve from cache
|
||||
*
|
||||
* @return mixed[] Array of retrieved values, indexed by the specified keys.
|
||||
* Values that couldn't be retrieved are not contained in this array.
|
||||
*/
|
||||
public function fetchMultiple(array $keys);
|
||||
}
|
12
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiOperationCache.php
vendored
Normal file
12
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiOperationCache.php
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that supports multiple items manipulation.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiOperationCache extends MultiGetCache, MultiDeleteCache, MultiPutCache
|
||||
{
|
||||
}
|
24
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php
vendored
Normal file
24
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to put many items at once.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiPutCache
|
||||
{
|
||||
/**
|
||||
* Returns a boolean value indicating if the operation succeeded.
|
||||
*
|
||||
* @param mixed[] $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
public function saveMultiple(array $keysAndValues, $lifetime = 0);
|
||||
}
|
340
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheAdapter.php
vendored
Normal file
340
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheAdapter.php
vendored
Normal file
|
@ -0,0 +1,340 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\ClearableCache;
|
||||
use Doctrine\Common\Cache\MultiDeleteCache;
|
||||
use Doctrine\Common\Cache\MultiGetCache;
|
||||
use Doctrine\Common\Cache\MultiPutCache;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\DoctrineProvider as SymfonyDoctrineProvider;
|
||||
|
||||
use function array_key_exists;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function current;
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function is_object;
|
||||
use function is_string;
|
||||
use function microtime;
|
||||
use function sprintf;
|
||||
use function strpbrk;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
final class CacheAdapter implements CacheItemPoolInterface
|
||||
{
|
||||
private const RESERVED_CHARACTERS = '{}()/\@:';
|
||||
|
||||
/** @var Cache */
|
||||
private $cache;
|
||||
|
||||
/** @var array<CacheItem|TypedCacheItem> */
|
||||
private $deferredItems = [];
|
||||
|
||||
public static function wrap(Cache $cache): CacheItemPoolInterface
|
||||
{
|
||||
if ($cache instanceof DoctrineProvider && ! $cache->getNamespace()) {
|
||||
return $cache->getPool();
|
||||
}
|
||||
|
||||
if ($cache instanceof SymfonyDoctrineProvider && ! $cache->getNamespace()) {
|
||||
$getPool = function () {
|
||||
// phpcs:ignore Squiz.Scope.StaticThisUsage.Found
|
||||
return $this->pool;
|
||||
};
|
||||
|
||||
return $getPool->bindTo($cache, SymfonyDoctrineProvider::class)();
|
||||
}
|
||||
|
||||
return new self($cache);
|
||||
}
|
||||
|
||||
private function __construct(Cache $cache)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public function getCache(): Cache
|
||||
{
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getItem($key): CacheItemInterface
|
||||
{
|
||||
assert(self::validKey($key));
|
||||
|
||||
if (isset($this->deferredItems[$key])) {
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
$value = $this->cache->fetch($key);
|
||||
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
if ($value !== false) {
|
||||
return new TypedCacheItem($key, $value, true);
|
||||
}
|
||||
|
||||
return new TypedCacheItem($key, null, false);
|
||||
}
|
||||
|
||||
if ($value !== false) {
|
||||
return new CacheItem($key, $value, true);
|
||||
}
|
||||
|
||||
return new CacheItem($key, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getItems(array $keys = []): array
|
||||
{
|
||||
if ($this->deferredItems) {
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
assert(self::validKeys($keys));
|
||||
|
||||
$values = $this->doFetchMultiple($keys);
|
||||
$items = [];
|
||||
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
foreach ($keys as $key) {
|
||||
if (array_key_exists($key, $values)) {
|
||||
$items[$key] = new TypedCacheItem($key, $values[$key], true);
|
||||
} else {
|
||||
$items[$key] = new TypedCacheItem($key, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (array_key_exists($key, $values)) {
|
||||
$items[$key] = new CacheItem($key, $values[$key], true);
|
||||
} else {
|
||||
$items[$key] = new CacheItem($key, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hasItem($key): bool
|
||||
{
|
||||
assert(self::validKey($key));
|
||||
|
||||
if (isset($this->deferredItems[$key])) {
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
return $this->cache->contains($key);
|
||||
}
|
||||
|
||||
public function clear(): bool
|
||||
{
|
||||
$this->deferredItems = [];
|
||||
|
||||
if (! $this->cache instanceof ClearableCache) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->cache->deleteAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deleteItem($key): bool
|
||||
{
|
||||
assert(self::validKey($key));
|
||||
unset($this->deferredItems[$key]);
|
||||
|
||||
return $this->cache->delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deleteItems(array $keys): bool
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
assert(self::validKey($key));
|
||||
unset($this->deferredItems[$key]);
|
||||
}
|
||||
|
||||
return $this->doDeleteMultiple($keys);
|
||||
}
|
||||
|
||||
public function save(CacheItemInterface $item): bool
|
||||
{
|
||||
return $this->saveDeferred($item) && $this->commit();
|
||||
}
|
||||
|
||||
public function saveDeferred(CacheItemInterface $item): bool
|
||||
{
|
||||
if (! $item instanceof CacheItem && ! $item instanceof TypedCacheItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->deferredItems[$item->getKey()] = $item;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function commit(): bool
|
||||
{
|
||||
if (! $this->deferredItems) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$now = microtime(true);
|
||||
$itemsCount = 0;
|
||||
$byLifetime = [];
|
||||
$expiredKeys = [];
|
||||
|
||||
foreach ($this->deferredItems as $key => $item) {
|
||||
$lifetime = ($item->getExpiry() ?? $now) - $now;
|
||||
|
||||
if ($lifetime < 0) {
|
||||
$expiredKeys[] = $key;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
++$itemsCount;
|
||||
$byLifetime[(int) $lifetime][$key] = $item->get();
|
||||
}
|
||||
|
||||
$this->deferredItems = [];
|
||||
|
||||
switch (count($expiredKeys)) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
$this->cache->delete(current($expiredKeys));
|
||||
break;
|
||||
default:
|
||||
$this->doDeleteMultiple($expiredKeys);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($itemsCount === 1) {
|
||||
return $this->cache->save($key, $item->get(), (int) $lifetime);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
foreach ($byLifetime as $lifetime => $values) {
|
||||
$success = $this->doSaveMultiple($values, $lifetime) && $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $key
|
||||
*/
|
||||
private static function validKey($key): bool
|
||||
{
|
||||
if (! is_string($key)) {
|
||||
throw new InvalidArgument(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
|
||||
}
|
||||
|
||||
if ($key === '') {
|
||||
throw new InvalidArgument('Cache key length must be greater than zero.');
|
||||
}
|
||||
|
||||
if (strpbrk($key, self::RESERVED_CHARACTERS) !== false) {
|
||||
throw new InvalidArgument(sprintf('Cache key "%s" contains reserved characters "%s".', $key, self::RESERVED_CHARACTERS));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $keys
|
||||
*/
|
||||
private static function validKeys(array $keys): bool
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
self::validKey($key);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $keys
|
||||
*/
|
||||
private function doDeleteMultiple(array $keys): bool
|
||||
{
|
||||
if ($this->cache instanceof MultiDeleteCache) {
|
||||
return $this->cache->deleteMultiple($keys);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
foreach ($keys as $key) {
|
||||
$success = $this->cache->delete($key) && $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $keys
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
private function doFetchMultiple(array $keys): array
|
||||
{
|
||||
if ($this->cache instanceof MultiGetCache) {
|
||||
return $this->cache->fetchMultiple($keys);
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($keys as $key) {
|
||||
$value = $this->cache->fetch($key);
|
||||
if (! $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values[$key] = $value;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $keysAndValues
|
||||
*/
|
||||
private function doSaveMultiple(array $keysAndValues, int $lifetime = 0): bool
|
||||
{
|
||||
if ($this->cache instanceof MultiPutCache) {
|
||||
return $this->cache->saveMultiple($keysAndValues, $lifetime);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
$success = $this->cache->save($key, $value, $lifetime) && $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
}
|
118
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheItem.php
vendored
Normal file
118
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheItem.php
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use TypeError;
|
||||
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function is_int;
|
||||
use function is_object;
|
||||
use function microtime;
|
||||
use function sprintf;
|
||||
|
||||
final class CacheItem implements CacheItemInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $key;
|
||||
/** @var mixed */
|
||||
private $value;
|
||||
/** @var bool */
|
||||
private $isHit;
|
||||
/** @var float|null */
|
||||
private $expiry;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param mixed $data
|
||||
*/
|
||||
public function __construct(string $key, $data, bool $isHit)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->value = $data;
|
||||
$this->isHit = $isHit;
|
||||
}
|
||||
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function isHit(): bool
|
||||
{
|
||||
return $this->isHit;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function set($value): self
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function expiresAt($expiration): self
|
||||
{
|
||||
if ($expiration === null) {
|
||||
$this->expiry = null;
|
||||
} elseif ($expiration instanceof DateTimeInterface) {
|
||||
$this->expiry = (float) $expiration->format('U.u');
|
||||
} else {
|
||||
throw new TypeError(sprintf(
|
||||
'Expected $expiration to be an instance of DateTimeInterface or null, got %s',
|
||||
is_object($expiration) ? get_class($expiration) : gettype($expiration)
|
||||
));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function expiresAfter($time): self
|
||||
{
|
||||
if ($time === null) {
|
||||
$this->expiry = null;
|
||||
} elseif ($time instanceof DateInterval) {
|
||||
$this->expiry = microtime(true) + DateTime::createFromFormat('U', 0)->add($time)->format('U.u');
|
||||
} elseif (is_int($time)) {
|
||||
$this->expiry = $time + microtime(true);
|
||||
} else {
|
||||
throw new TypeError(sprintf(
|
||||
'Expected $time to be either an integer, an instance of DateInterval or null, got %s',
|
||||
is_object($time) ? get_class($time) : gettype($time)
|
||||
));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function getExpiry(): ?float
|
||||
{
|
||||
return $this->expiry;
|
||||
}
|
||||
}
|
135
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/DoctrineProvider.php
vendored
Normal file
135
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/DoctrineProvider.php
vendored
Normal file
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\CacheProvider;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\DoctrineAdapter as SymfonyDoctrineAdapter;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
use function rawurlencode;
|
||||
|
||||
/**
|
||||
* This class was copied from the Symfony Framework, see the original copyright
|
||||
* notice above. The code is distributed subject to the license terms in
|
||||
* https://github.com/symfony/symfony/blob/ff0cf61278982539c49e467db9ab13cbd342f76d/LICENSE
|
||||
*/
|
||||
final class DoctrineProvider extends CacheProvider
|
||||
{
|
||||
/** @var CacheItemPoolInterface */
|
||||
private $pool;
|
||||
|
||||
public static function wrap(CacheItemPoolInterface $pool): Cache
|
||||
{
|
||||
if ($pool instanceof CacheAdapter) {
|
||||
return $pool->getCache();
|
||||
}
|
||||
|
||||
if ($pool instanceof SymfonyDoctrineAdapter) {
|
||||
$getCache = function () {
|
||||
// phpcs:ignore Squiz.Scope.StaticThisUsage.Found
|
||||
return $this->provider;
|
||||
};
|
||||
|
||||
return $getCache->bindTo($pool, SymfonyDoctrineAdapter::class)();
|
||||
}
|
||||
|
||||
return new self($pool);
|
||||
}
|
||||
|
||||
private function __construct(CacheItemPoolInterface $pool)
|
||||
{
|
||||
$this->pool = $pool;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public function getPool(): CacheItemPoolInterface
|
||||
{
|
||||
return $this->pool;
|
||||
}
|
||||
|
||||
public function reset(): void
|
||||
{
|
||||
if ($this->pool instanceof ResetInterface) {
|
||||
$this->pool->reset();
|
||||
}
|
||||
|
||||
$this->setNamespace($this->getNamespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$item = $this->pool->getItem(rawurlencode($id));
|
||||
|
||||
return $item->isHit() ? $item->get() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return $this->pool->hasItem(rawurlencode($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$item = $this->pool->getItem(rawurlencode($id));
|
||||
|
||||
if (0 < $lifeTime) {
|
||||
$item->expiresAfter($lifeTime);
|
||||
}
|
||||
|
||||
return $this->pool->save($item->set($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->pool->deleteItem(rawurlencode($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->pool->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
13
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/InvalidArgument.php
vendored
Normal file
13
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/InvalidArgument.php
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Psr\Cache\InvalidArgumentException as PsrInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class InvalidArgument extends InvalidArgumentException implements PsrInvalidArgumentException
|
||||
{
|
||||
}
|
99
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/TypedCacheItem.php
vendored
Normal file
99
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/TypedCacheItem.php
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use TypeError;
|
||||
|
||||
use function get_debug_type;
|
||||
use function is_int;
|
||||
use function microtime;
|
||||
use function sprintf;
|
||||
|
||||
final class TypedCacheItem implements CacheItemInterface
|
||||
{
|
||||
private ?float $expiry = null;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __construct(
|
||||
private string $key,
|
||||
private mixed $value,
|
||||
private bool $isHit,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function get(): mixed
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function isHit(): bool
|
||||
{
|
||||
return $this->isHit;
|
||||
}
|
||||
|
||||
public function set(mixed $value): static
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function expiresAt($expiration): static
|
||||
{
|
||||
if ($expiration === null) {
|
||||
$this->expiry = null;
|
||||
} elseif ($expiration instanceof DateTimeInterface) {
|
||||
$this->expiry = (float) $expiration->format('U.u');
|
||||
} else {
|
||||
throw new TypeError(sprintf(
|
||||
'Expected $expiration to be an instance of DateTimeInterface or null, got %s',
|
||||
get_debug_type($expiration)
|
||||
));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function expiresAfter($time): static
|
||||
{
|
||||
if ($time === null) {
|
||||
$this->expiry = null;
|
||||
} elseif ($time instanceof DateInterval) {
|
||||
$this->expiry = microtime(true) + DateTime::createFromFormat('U', 0)->add($time)->format('U.u');
|
||||
} elseif (is_int($time)) {
|
||||
$this->expiry = $time + microtime(true);
|
||||
} else {
|
||||
throw new TypeError(sprintf(
|
||||
'Expected $time to be either an integer, an instance of DateInterval or null, got %s',
|
||||
get_debug_type($time)
|
||||
));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function getExpiry(): ?float
|
||||
{
|
||||
return $this->expiry;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue