20
20
use Generator ;
21
21
22
22
use function is_int ;
23
- use function is_iterable ;
24
23
use function is_object ;
25
- use function is_string ;
26
24
27
25
use Laudis \Neo4j \Exception \InvalidCacheArgumentException ;
28
26
@@ -53,9 +51,7 @@ class Cache implements CacheInterface
53
51
private array $ items = [];
54
52
private static ?self $ instance = null ;
55
53
56
- private function __construct ()
57
- {
58
- }
54
+ private function __construct () {}
59
55
60
56
public static function getInstance (): self
61
57
{
@@ -69,7 +65,6 @@ public static function getInstance(): self
69
65
/**
70
66
* @template U
71
67
*
72
- * @param string $key
73
68
* @param U $default
74
69
*
75
70
* @return T|U
@@ -102,8 +97,6 @@ public function clear(): bool
102
97
*/
103
98
public function deleteMultiple (iterable $ keys ): bool
104
99
{
105
- $ this ->assertIterable ($ keys );
106
-
107
100
foreach ($ keys as $ key ) {
108
101
$ this ->delete ($ key );
109
102
}
@@ -122,10 +115,8 @@ public function set(string $key, mixed $value, int|DateInterval|null $ttl = null
122
115
$ ttl = (new DateTimeImmutable ())->add ($ ttl )->getTimestamp ();
123
116
} elseif ($ ttl === null ) {
124
117
$ ttl = PHP_INT_MAX ;
125
- } elseif (is_int ($ ttl )) {
126
- $ ttl += time ();
127
118
} else {
128
- throw new InvalidCacheArgumentException ();
119
+ $ ttl += time ();
129
120
}
130
121
131
122
if (is_object ($ value )) {
@@ -150,14 +141,12 @@ public function delete($key): bool
150
141
* @template U
151
142
*
152
143
* @param iterable<string> $keys
153
- * @param U $default
144
+ * @param U $default
154
145
*
155
146
* @return Generator<string, T|U>
156
147
*/
157
148
public function getMultiple ($ keys , $ default = null ): Generator
158
149
{
159
- $ this ->assertIterable ($ keys );
160
-
161
150
/** @var list<string> $cachedKeys */
162
151
$ cachedKeys = [];
163
152
foreach ($ keys as $ key ) {
@@ -173,18 +162,16 @@ public function getMultiple($keys, $default = null): Generator
173
162
}
174
163
175
164
/**
176
- * @param iterable<string, T> $values
165
+ * @param iterable<string, T> $values
177
166
* @param int|DateInterval|null $ttl
178
167
*
179
168
* @throws InvalidCacheArgumentException
180
169
*/
181
170
public function setMultiple (iterable $ values , null |int |DateInterval $ ttl = null ): bool
182
171
{
183
- $ this ->assertIterable ($ values );
184
-
185
172
foreach ($ values as $ key => $ value ) {
186
173
if (is_int ($ key )) {
187
- $ key = (string )$ key ;
174
+ $ key = (string ) $ key ;
188
175
}
189
176
$ this ->set ($ key , $ value , $ ttl );
190
177
}
0 commit comments