Skip to content

Commit 4241f9a

Browse files
committed
Fix new ShopwareRedisAdapter usage
1 parent 936b676 commit 4241f9a

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/Components/CacheAdapter.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
1111
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
1212
use Symfony\Component\Cache\Adapter\RedisAdapter;
13+
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
1314
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
1415
use Symfony\Component\Cache\Adapter\TraceableAdapter;
1516

@@ -26,6 +27,7 @@ public function getSize(): int
2627
{
2728
switch (true) {
2829
case $this->adapter instanceof RedisAdapter:
30+
case $this->adapter instanceof RedisTagAwareAdapter:
2931
return $this->getRedis($this->adapter)->info()['used_memory'];
3032
case $this->adapter instanceof FilesystemAdapter:
3133
return CacheHelper::getSize($this->getPathFromFilesystemAdapter($this->adapter));
@@ -46,6 +48,7 @@ public function getFreeSize(): ?int
4648
{
4749
switch (true) {
4850
case $this->adapter instanceof RedisAdapter:
51+
case $this->adapter instanceof RedisTagAwareAdapter:
4952
$info = $this->getRedis($this->adapter)->info();
5053
if ($info['maxmemory'] === 0) {
5154
return -1;
@@ -70,6 +73,7 @@ public function clear(): void
7073
CacheHelper::removeDir($this->getPathFromFilesystemAdapter($this->adapter));
7174
break;
7275
case $this->adapter instanceof RedisAdapter:
76+
case $this->adapter instanceof RedisTagAwareAdapter:
7377
try {
7478
$this->getRedis($this->adapter)->flushDB();
7579
} catch (\Exception $e) {
@@ -86,6 +90,7 @@ public function getType(): string
8690
{
8791
switch (true) {
8892
case $this->adapter instanceof RedisAdapter:
93+
case $this->adapter instanceof RedisTagAwareAdapter:
8994
return 'Redis ' . $this->getRedis($this->adapter)->info()['redis_version'];
9095
case $this->adapter instanceof FilesystemAdapter:
9196
return 'Filesystem';
@@ -125,9 +130,16 @@ private function getCacheAdapter(AdapterInterface $adapter): AdapterInterface
125130

126131
private function getRedis(AdapterInterface $adapter): ?\Redis
127132
{
128-
$redisProxyGetter = \Closure::bind(function () use ($adapter) {
129-
return $adapter->redis;
130-
}, $adapter, \get_class($adapter));
133+
if ($adapter instanceof RedisTagAwareAdapter) {
134+
$redisProxyGetter = \Closure::bind(function () use ($adapter) {
135+
return $adapter->redis;
136+
}, $adapter, RedisTagAwareAdapter::class);
137+
} else {
138+
$redisProxyGetter = \Closure::bind(function () use ($adapter) {
139+
return $adapter->redis;
140+
}, $adapter, RedisAdapter::class);
141+
}
142+
131143
$redisProxy = $redisProxyGetter($adapter);
132144

133145
$redisGetter = \Closure::bind(function () use ($redisProxy) {

0 commit comments

Comments
 (0)