| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class Redis implements Storing |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var API |
||
| 18 | */ |
||
| 19 | private $backend = null; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Redis constructor. |
||
| 23 | * @param API $backend |
||
| 24 | */ |
||
| 25 | public function __construct($backend) |
||
| 26 | { |
||
| 27 | $this->backend = $backend; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $key |
||
| 32 | * @return bool |
||
| 33 | */ |
||
| 34 | public function has(string $key) |
||
| 35 | { |
||
| 36 | return (yield $this->backend->exists($key)) ? true : false; |
||
|
|
|||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param string $key |
||
| 41 | * @return mixed |
||
| 42 | */ |
||
| 43 | public function read(string $key) |
||
| 44 | { |
||
| 45 | return yield $this->backend->get($key); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param string $key |
||
| 50 | * @param mixed $data |
||
| 51 | * @param int $ttl |
||
| 52 | * @return bool |
||
| 53 | */ |
||
| 54 | public function write(string $key, $data, int $ttl = null) |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param string $key |
||
| 61 | * @return bool |
||
| 62 | */ |
||
| 63 | public function remove(string $key) |
||
| 68 |