diff --git a/DataStorage/Cache/Connection/RedisCache.php b/DataStorage/Cache/Connection/RedisCache.php index 784490055..46613e979 100755 --- a/DataStorage/Cache/Connection/RedisCache.php +++ b/DataStorage/Cache/Connection/RedisCache.php @@ -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; diff --git a/tests/DataStorage/Cache/Connection/RedisCacheTest.php b/tests/DataStorage/Cache/Connection/RedisCacheTest.php index 3a91050be..a64aac39a 100755 --- a/tests/DataStorage/Cache/Connection/RedisCacheTest.php +++ b/tests/DataStorage/Cache/Connection/RedisCacheTest.php @@ -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')); }