Skip to content

Commit 9770d8d

Browse files
committed
feat: APCu caching driver: keys iterator improvement, fixes
1 parent 79942cb commit 9770d8d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

system/Cache/Handlers/ApcuHandler.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public function delete(string $key): bool
9090
public function deleteMatching(string $pattern): int
9191
{
9292
$matchedKeys = array_filter(
93-
array_keys(iterator_to_array(new APCUIterator())),
94-
static fn ($key) => fnmatch($pattern, $key),
93+
array_keys(iterator_to_array(new APCUIterator(null, APC_ITER_KEY))),
94+
static fn ($key): bool => fnmatch($pattern, $key),
9595
);
9696

97-
if ($matchedKeys) {
97+
if ($matchedKeys !== []) {
9898
return count($matchedKeys) - count(apcu_delete($matchedKeys));
9999
}
100100

@@ -142,9 +142,10 @@ public function getCacheInfo(): array|false|object|null
142142
*/
143143
public function getMetaData(string $key): ?array
144144
{
145-
$key = static::validateKey($key, $this->prefix);
145+
$key = static::validateKey($key, $this->prefix);
146+
$metadata = apcu_key_info($key);
146147

147-
if ($metadata = apcu_key_info($key)) {
148+
if ($metadata !== null) {
148149
return [
149150
'expire' => $metadata['ttl'] > 0 ? Time::now()->getTimestamp() + $metadata['ttl'] : null,
150151
'mtime' => $metadata['mtime'],

0 commit comments

Comments
 (0)