Skip to content

Commit 7109103

Browse files
authored
Merge pull request #23 from byjg/6.0
Optimize `clear()` method in RedisCacheEngine and add Docker config
2 parents 3904cfb + edf3f42 commit 7109103

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.run/Services for Test.run.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Services for Test" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
3+
<deployment type="docker-compose.yml">
4+
<settings>
5+
<option name="sourceFilePath" value="docker-compose.yml" />
6+
</settings>
7+
</deployment>
8+
<method v="2" />
9+
</configuration>
10+
</component>

src/Psr16/RedisCacheEngine.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,13 @@ public function delete(string $key): bool
159159
#[\Override]
160160
public function clear(): bool
161161
{
162-
$keys = $this->redis->keys('cache:*');
163-
foreach ($keys as $key) {
164-
if (preg_match('/^cache:(?<key>.*)/', $key, $matches)) {
165-
$this->delete($matches['key']);
162+
$iterator = null;
163+
do {
164+
$keys = $this->redis->scan($iterator, 'cache:*');
165+
foreach($keys as $key) {
166+
$this->delete(substr($key, 6));
166167
}
167-
}
168+
} while($iterator !== 0);
168169
return true;
169170
}
170171

0 commit comments

Comments
 (0)