1 | <?php namespace AdammBalogh\KeyValueStore\Implementation; |
||
10 | trait KeyTrait |
||
11 | { |
||
12 | use AdapterTrait; |
||
13 | |||
14 | /** |
||
15 | * Removes a key. |
||
16 | * |
||
17 | * @param string $key |
||
18 | * |
||
19 | * @return bool True if the deletion was successful, false if the deletion was unsuccessful. |
||
20 | * |
||
21 | * @throws \InvalidArgumentException |
||
22 | * @throws InternalException |
||
23 | */ |
||
24 | public function delete($key) |
||
34 | |||
35 | /** |
||
36 | * Sets a key's time to live in seconds. |
||
37 | * |
||
38 | * @param string $key |
||
39 | * @param int $seconds |
||
40 | * |
||
41 | * @return bool True if the timeout was set, false if the timeout could not be set. |
||
42 | * |
||
43 | * @throws \InvalidArgumentException |
||
44 | * @throws InternalException |
||
45 | */ |
||
46 | public function expire($key, $seconds) |
||
57 | |||
58 | /** |
||
59 | * Returns the remaining time to live of a key that has a timeout. |
||
60 | * |
||
61 | * @param string $key |
||
62 | * |
||
63 | * @return int Ttl in seconds. |
||
64 | * |
||
65 | * @throws \InvalidArgumentException |
||
66 | * @throws KeyNotFoundException |
||
67 | * @throws InternalException |
||
68 | */ |
||
69 | public function getTtl($key) |
||
81 | |||
82 | /** |
||
83 | * Determines if a key exists. |
||
84 | * |
||
85 | * @param string $key |
||
86 | * |
||
87 | * @return bool True if the key does exist, false if the key does not exist. |
||
88 | * |
||
89 | * @throws \InvalidArgumentException |
||
90 | * @throws InternalException |
||
91 | */ |
||
92 | public function has($key) |
||
102 | |||
103 | /** |
||
104 | * Removes the existing timeout on key, turning the key from volatile (a key with an expire set) |
||
105 | * to persistent (a key that will never expire as no timeout is associated). |
||
106 | * |
||
107 | * @param string $key |
||
108 | * |
||
109 | * @return bool True if the persist was success, false if the persis was unsuccessful. |
||
110 | * |
||
111 | * @throws \InvalidArgumentException |
||
112 | * @throws InternalException |
||
113 | */ |
||
114 | public function persist($key) |
||
124 | } |
||
125 |