CacheInterface.php
2 years ago
DoctrineBridge.php
2 years ago
LaravelCache.php
2 years ago
PSR16Bridge.php
2 years ago
PSR6Bridge.php
2 years ago
StaticCache.php
2 years ago
PSR16Bridge.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Device Detector - The Universal Device Detection library for parsing User Agents |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * |
| 8 | * @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later |
| 9 | */ |
| 10 | declare (strict_types=1); |
| 11 | namespace IAWPSCOPED\DeviceDetector\Cache; |
| 12 | |
| 13 | use IAWPSCOPED\Psr\SimpleCache\CacheInterface as PsrCacheInterface; |
| 14 | /** @internal */ |
| 15 | class PSR16Bridge implements CacheInterface |
| 16 | { |
| 17 | /** |
| 18 | * @var PsrCacheInterface |
| 19 | */ |
| 20 | private $cache; |
| 21 | /** |
| 22 | * PSR16Bridge constructor. |
| 23 | * @param PsrCacheInterface $cache |
| 24 | */ |
| 25 | public function __construct(PsrCacheInterface $cache) |
| 26 | { |
| 27 | $this->cache = $cache; |
| 28 | } |
| 29 | /** |
| 30 | * @inheritDoc |
| 31 | */ |
| 32 | public function fetch(string $id) |
| 33 | { |
| 34 | return $this->cache->get($id, \false); |
| 35 | } |
| 36 | /** |
| 37 | * @inheritDoc |
| 38 | */ |
| 39 | public function contains(string $id) : bool |
| 40 | { |
| 41 | return $this->cache->has($id); |
| 42 | } |
| 43 | /** |
| 44 | * @inheritDoc |
| 45 | */ |
| 46 | public function save(string $id, $data, int $lifeTime = 0) : bool |
| 47 | { |
| 48 | return $this->cache->set($id, $data, \func_num_args() < 3 ? null : $lifeTime); |
| 49 | } |
| 50 | /** |
| 51 | * @inheritDoc |
| 52 | */ |
| 53 | public function delete(string $id) : bool |
| 54 | { |
| 55 | return $this->cache->delete($id); |
| 56 | } |
| 57 | /** |
| 58 | * @inheritDoc |
| 59 | */ |
| 60 | public function flushAll() : bool |
| 61 | { |
| 62 | return $this->cache->clear(); |
| 63 | } |
| 64 | } |
| 65 |