| Total Complexity | 8 |
| Total Lines | 74 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | abstract class AbstractCache implements Cacheable |
||
| 6 | { |
||
| 7 | /** @var int TTL in secs (default 1 day) */ |
||
| 8 | protected $ttl = 86400; |
||
| 9 | |||
| 10 | /** @var string Prefix for cache keys */ |
||
| 11 | protected $prefix = 'tus:'; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Set time to live. |
||
| 15 | * |
||
| 16 | * @param int $secs |
||
| 17 | * |
||
| 18 | * @return self |
||
| 19 | */ |
||
| 20 | 3 | public function setTtl(int $secs) : self |
|
| 21 | { |
||
| 22 | 3 | $this->ttl = $secs; |
|
| 23 | |||
| 24 | 3 | return $this; |
|
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * {@inheritDoc} |
||
| 29 | */ |
||
| 30 | 1 | public function getTtl() : int |
|
| 31 | { |
||
| 32 | 1 | return $this->ttl; |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Set cache prefix. |
||
| 37 | * |
||
| 38 | * @param string $prefix |
||
| 39 | * |
||
| 40 | * @return Cacheable |
||
| 41 | */ |
||
| 42 | 5 | public function setPrefix(string $prefix) : Cacheable |
|
| 43 | { |
||
| 44 | 5 | $this->prefix = $prefix; |
|
| 45 | |||
| 46 | 5 | return $this; |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Get cache prefix. |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | 3 | public function getPrefix() : string |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Delete all keys. |
||
| 61 | * |
||
| 62 | * @param array $keys |
||
| 63 | * |
||
| 64 | * @return bool |
||
| 65 | */ |
||
| 66 | 3 | public function deleteAll(array $keys) : bool |
|
| 79 | } |
||
| 80 | } |
||
| 81 |