|
10 | 10 | interface StorageInterface |
11 | 11 | { |
12 | 12 | /** |
13 | | - * Put `$value` if `$key` value matches `$previousValue` otherwise `$returnNewValueOnFail` |
| 13 | + * Put `$value` if `$key` value matches `$previousValue` and return true. If the new value does not match and |
| 14 | + * `$returnNewValueOnFail` is true return the new value, otherwise return false. |
14 | 15 | * @param string $key |
15 | 16 | * @param string $value The new value to set |
16 | | - * @param bool|string $previousValue The previous value to compare against |
17 | | - * @param bool $returnNewValueOnFail |
18 | | - * @return bool|string |
| 17 | + * @param string|null $previousValue The previous value to compare against. If null is provided, the comparison |
| 18 | + * should check that the key does not exist yet. |
| 19 | + * @param bool $returnNewValueOnFail if true the new value of the key should be returned if the operation fails |
| 20 | + * @return bool|string true if the operation succeeded, false if it failed and `$returnNewValueOnFail` is false, |
| 21 | + * otherwise the new value of the key |
19 | 22 | * @throws StorageException a known, retryable error occurred |
20 | 23 | * @throws Exception an unknown error occurred |
21 | 24 | */ |
22 | | - public function putIf(string $key, string $value, bool|string $previousValue, bool $returnNewValueOnFail): bool|string; |
| 25 | + public function putIf(string $key, string $value, ?string $previousValue, bool $returnNewValueOnFail): bool|string; |
23 | 26 |
|
24 | 27 | /** |
25 | 28 | * Delete if $key value matches $previous value otherwise $returnNewValueOnFail |
26 | 29 | * |
27 | 30 | * @param string $key |
28 | | - * @param bool|string $previousValue The previous value to compare against |
| 31 | + * @param string|null $previousValue The previous value to compare against. If null is provided, the comparison |
| 32 | + * should check that the key does not exist yet. |
29 | 33 | * @param bool $returnNewValueOnFail |
30 | | - * @return bool|string |
| 34 | + * @return bool|string true if the operation succeeded, false if it failed and `$returnNewValueOnFail` is false, |
| 35 | + * otherwise the new value of the key |
31 | 36 | * @throws StorageException a known, retryable error occurred |
32 | 37 | * @throws Exception an unknown error occurred |
33 | 38 | */ |
34 | | - public function deleteIf(string $key, bool|string $previousValue, bool $returnNewValueOnFail = false): bool|string; |
| 39 | + public function deleteIf(string $key, ?string $previousValue, bool $returnNewValueOnFail = false): bool|string; |
35 | 40 |
|
36 | 41 | /** |
37 | 42 | * Get the value of a key |
38 | 43 | * @param string $key |
39 | | - * @return bool|string |
| 44 | + * @return string|null the value of the key or null if the key does not exist |
40 | 45 | * @throws StorageException a known, retryable error occurred |
41 | 46 | * @throws Exception an unknown error occurred |
42 | 47 | */ |
43 | | - public function get(string $key): bool|string; |
| 48 | + public function get(string $key): ?string; |
44 | 49 | } |
0 commit comments