1 | <?php namespace AdammBalogh\KeyValueStore\Adapter\SharedMemoryAdapter; |
||
9 | trait ValueTrait |
||
10 | { |
||
11 | /** |
||
12 | * Gets the value of a key. |
||
13 | * |
||
14 | * @param string $key |
||
15 | * |
||
16 | * @return mixed The value of the key. |
||
17 | * |
||
18 | * @throws KeyNotFoundException |
||
19 | * @throws \Exception |
||
20 | */ |
||
21 | public function get($key) |
||
25 | |||
26 | /** |
||
27 | * Sets the value of a key. |
||
28 | * |
||
29 | * @param string $key |
||
30 | * @param mixed $value Can be any of serializable data type. |
||
31 | * |
||
32 | * @return bool True if the set was successful, false if it was unsuccessful. |
||
33 | * |
||
34 | * @throws \Exception |
||
35 | */ |
||
36 | public function set($key, $value) |
||
44 | |||
45 | /** |
||
46 | * Gets value, watches expiring. |
||
47 | * |
||
48 | * @param string $key |
||
49 | * |
||
50 | * @return mixed |
||
51 | * |
||
52 | * @throws KeyNotFoundException |
||
53 | * @throws \Exception |
||
54 | */ |
||
55 | protected function getValue($key) |
||
72 | |||
73 | /** |
||
74 | * If ttl is lesser or equals 0 delete key. |
||
75 | * |
||
76 | * @param string $key |
||
77 | * @param int $expireSetTs |
||
78 | * @param int $expireSec |
||
79 | * |
||
80 | * @return int ttl |
||
81 | * |
||
82 | * @throws KeyNotFoundException |
||
83 | * @throws \Exception |
||
84 | */ |
||
85 | protected function handleTtl($key, $expireSetTs, $expireSec) |
||
98 | } |
||
99 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: