Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php declare(strict_types=1); |
2 | /** |
3 | * Banker |
4 | * |
5 | * A Caching library implementing psr/cache (PSR 6) and psr/simple-cache (PSR 16) |
6 | * |
7 | * PHP version 8+ |
8 | * |
9 | * @package Banker |
10 | * @author Timothy J. Warren <tim@timshomepage.net> |
11 | * @copyright 2016 - 2023 Timothy J. Warren |
12 | * @license http://www.opensource.org/licenses/mit-license.html MIT License |
13 | * @version 4.1.0 |
14 | * @link https://git.timshomepage.net/timw4mail/banker |
15 | */ |
16 | namespace Aviat\Banker\Driver; |
17 | |
18 | use DateInterval; |
19 | |
20 | /** |
21 | * Interface for different cache backends |
22 | */ |
23 | interface DriverInterface { |
24 | |
25 | /** |
26 | * See if a key exists in the cache |
27 | * |
28 | * @param string $key |
29 | * @return bool |
30 | */ |
31 | public function exists(string $key): bool; |
32 | |
33 | /** |
34 | * Set a cached value |
35 | * |
36 | * @param string $key |
37 | * @param mixed $value |
38 | * @param DateInterval|int|null $expires |
39 | * @return bool |
40 | */ |
41 | public function set(string $key, mixed $value, DateInterval|int|null $expires = NULL): bool; |
42 | |
43 | /** |
44 | * Get the value for the selected cache key |
45 | * |
46 | * @param string $key |
47 | * @return mixed |
48 | */ |
49 | public function get(string $key): mixed; |
50 | |
51 | /** |
52 | * Retrieve a set of values by their cache key |
53 | * |
54 | * @param string[] $keys |
55 | * @return array |
56 | */ |
57 | public function getMultiple(array $keys = []): array; |
58 | |
59 | /** |
60 | * Set multiple cache values |
61 | * |
62 | * @param array $items |
63 | * @param int|null $expires |
64 | * @return bool |
65 | */ |
66 | public function setMultiple(array $items, ?int $expires = NULL): bool; |
67 | |
68 | /** |
69 | * Remove an item from the cache |
70 | * |
71 | * @param string $key |
72 | * @return boolean |
73 | */ |
74 | public function delete(string $key): bool; |
75 | |
76 | /** |
77 | * Remove multiple items from the cache |
78 | * |
79 | * @param string[] $keys |
80 | * @return boolean |
81 | */ |
82 | public function deleteMultiple(array $keys = []): bool; |
83 | |
84 | /** |
85 | * Empty the cache |
86 | * |
87 | * @return boolean |
88 | */ |
89 | public function flush(): bool; |
90 | |
91 | /** |
92 | * Set the specified key to expire at the given time |
93 | * |
94 | * @param string $key |
95 | * @param int $expires |
96 | * @return boolean |
97 | */ |
98 | public function expiresAt(string $key, int $expires): bool; |
99 | } |