| Total Complexity | 8 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | final class Memcached extends AbstractAdapter |
||
| 11 | { |
||
| 12 | private \Memcached $memcached; |
||
| 13 | |||
| 14 | private function __construct(\Memcached $memcached) |
||
| 15 | { |
||
| 16 | Assertions::assertExtensionLoaded('memcached'); |
||
| 17 | $this->memcached = $memcached; |
||
| 18 | } |
||
| 19 | |||
| 20 | public static function create(\Memcached $memcached): SimpleCache\CacheInterface |
||
| 21 | { |
||
| 22 | return new self($memcached); |
||
| 23 | } |
||
| 24 | |||
| 25 | protected function flush(): bool |
||
| 26 | { |
||
| 27 | return $this->memcached->flush(); |
||
| 28 | } |
||
| 29 | |||
| 30 | protected function exists(string $key): bool |
||
| 31 | { |
||
| 32 | return $this->memcached->get($key) !== false; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @inheritDoc |
||
| 37 | */ |
||
| 38 | protected function multiGet(array $keys, $default = null): \Generator |
||
| 39 | { |
||
| 40 | foreach ($this->memcached->getMulti($keys, \Memcached::GET_PRESERVE_ORDER) as $key => $value) { |
||
| 41 | yield $key => $value ?? $default; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | protected function multiDelete(array $keys): bool |
||
| 46 | { |
||
| 47 | return count($this->memcached->deleteMulti($keys)) === count($keys); |
||
| 48 | } |
||
| 49 | |||
| 50 | protected function multiSave(array $values, int $ttl = null): bool |
||
| 53 | } |
||
| 54 | } |
||
| 55 |