diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/symfony/cache/Adapter/Psr16Adapter.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/symfony/cache/Adapter/Psr16Adapter.php')
| -rw-r--r-- | vendor/symfony/cache/Adapter/Psr16Adapter.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/vendor/symfony/cache/Adapter/Psr16Adapter.php b/vendor/symfony/cache/Adapter/Psr16Adapter.php new file mode 100644 index 0000000..a72b037 --- /dev/null +++ b/vendor/symfony/cache/Adapter/Psr16Adapter.php | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Cache\Adapter; | ||
| 13 | |||
| 14 | use Psr\SimpleCache\CacheInterface; | ||
| 15 | use Symfony\Component\Cache\PruneableInterface; | ||
| 16 | use Symfony\Component\Cache\ResettableInterface; | ||
| 17 | use Symfony\Component\Cache\Traits\ProxyTrait; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * Turns a PSR-16 cache into a PSR-6 one. | ||
| 21 | * | ||
| 22 | * @author Nicolas Grekas <p@tchwork.com> | ||
| 23 | */ | ||
| 24 | class Psr16Adapter extends AbstractAdapter implements PruneableInterface, ResettableInterface | ||
| 25 | { | ||
| 26 | use ProxyTrait; | ||
| 27 | |||
| 28 | /** | ||
| 29 | * @internal | ||
| 30 | */ | ||
| 31 | protected const NS_SEPARATOR = '_'; | ||
| 32 | |||
| 33 | private object $miss; | ||
| 34 | |||
| 35 | public function __construct(CacheInterface $pool, string $namespace = '', int $defaultLifetime = 0) | ||
| 36 | { | ||
| 37 | parent::__construct($namespace, $defaultLifetime); | ||
| 38 | |||
| 39 | $this->pool = $pool; | ||
| 40 | $this->miss = new \stdClass(); | ||
| 41 | } | ||
| 42 | |||
| 43 | protected function doFetch(array $ids): iterable | ||
| 44 | { | ||
| 45 | foreach ($this->pool->getMultiple($ids, $this->miss) as $key => $value) { | ||
| 46 | if ($this->miss !== $value) { | ||
| 47 | yield $key => $value; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | protected function doHave(string $id): bool | ||
| 53 | { | ||
| 54 | return $this->pool->has($id); | ||
| 55 | } | ||
| 56 | |||
| 57 | protected function doClear(string $namespace): bool | ||
| 58 | { | ||
| 59 | return $this->pool->clear(); | ||
| 60 | } | ||
| 61 | |||
| 62 | protected function doDelete(array $ids): bool | ||
| 63 | { | ||
| 64 | return $this->pool->deleteMultiple($ids); | ||
| 65 | } | ||
| 66 | |||
| 67 | protected function doSave(array $values, int $lifetime): array|bool | ||
| 68 | { | ||
| 69 | return $this->pool->setMultiple($values, 0 === $lifetime ? null : $lifetime); | ||
| 70 | } | ||
| 71 | } | ||
