cache fixes

This commit is contained in:
Dennis Eichhorn 2024-05-18 23:47:56 +02:00
parent 4b8475f890
commit 991d7d2b80
2 changed files with 14 additions and 12 deletions

View File

@ -113,7 +113,7 @@ final class RedisCache extends ConnectionAbstract
}
if ($expire > 0) {
$this->con->set((string) $key, $expire, $this->build($value));
$this->con->set((string) $key, $this->build($value), $expire);
return;
}
@ -247,17 +247,19 @@ final class RedisCache extends ConnectionAbstract
$values = [];
foreach ($keys as $key) {
if (\preg_match('/' . $pattern . '/', $key) === 1) {
$result = $this->con->get((string) $key);
if (\is_string($result) && ($result[0] ?? null) === self::DELIM) {
$result = \substr($result, 1);
$type = (int) $result[0];
$start = (int) \strpos($result, self::DELIM);
$result = $this->reverseValue($type, $result, $start);
}
$values[] = $result;
if (\preg_match('/' . $pattern . '/', $key) !== 1) {
continue;
}
$result = $this->con->get((string) $key);
if (\is_string($result) && ($result[0] ?? null) === self::DELIM) {
$result = \substr($result, 1);
$type = (int) $result[0];
$start = (int) \strpos($result, self::DELIM);
$result = $this->reverseValue($type, $result, $start);
}
$values[] = $result;
}
return $values;

View File

@ -156,7 +156,7 @@ final class RedisCacheTest extends \PHPUnit\Framework\TestCase
$this->cache->set('key2', 'testVal2', 2);
\sleep(1);
self::assertEquals([], \array_diff(['testVal1', 'testVal2'], $this->cache->getLike('key\d')));
self::assertEquals([], \array_diff(['testVal1', 'testVal2'], $this->cache->getLike('key\d', 0)));
self::assertEquals([], \array_diff(['testVal1', 'testVal2'], $this->cache->getLike('key\d', 0)));
\sleep(3);
self::assertEquals([], $this->cache->getLike('key\d'));
}