carno-php /
cache
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Apcu storing (shared memory) |
||
| 4 | * User: moyo |
||
| 5 | * Date: 2018/7/11 |
||
| 6 | * Time: 10:41 AM |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace Carno\Cache\Stores; |
||
| 10 | |||
| 11 | use Carno\Cache\Contracts\Storing; |
||
| 12 | |||
| 13 | class Apcu implements Storing |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @param string $key |
||
| 17 | * @return bool |
||
| 18 | */ |
||
| 19 | public function has(string $key) : bool |
||
| 20 | { |
||
| 21 | return apcu_exists($key); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param string $key |
||
| 26 | * @return mixed |
||
| 27 | */ |
||
| 28 | public function read(string $key) |
||
| 29 | { |
||
| 30 | return apcu_fetch($key); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param string $key |
||
| 35 | * @param mixed $data |
||
| 36 | * @param int $ttl |
||
| 37 | * @return bool |
||
| 38 | */ |
||
| 39 | public function write(string $key, $data, int $ttl = null) : bool |
||
| 40 | { |
||
| 41 | return apcu_store($key, $data, $ttl ?? 0); |
||
|
0 ignored issues
–
show
|
|||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param string $key |
||
| 46 | * @return bool |
||
| 47 | */ |
||
| 48 | public function remove(string $key) : bool |
||
| 49 | { |
||
| 50 | return apcu_delete($key); |
||
|
0 ignored issues
–
show
|
|||
| 51 | } |
||
| 52 | } |
||
| 53 |