RedisInvalidatorStorage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 3 1
A loadAndDelete() 0 11 1
A __construct() 0 2 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Framework\Adapter\Cache\InvalidatorStorage;
4
5
use Shopware\Core\Framework\Log\Package;
6
7
#[Package('core')]
8
class RedisInvalidatorStorage extends AbstractInvalidatorStorage
9
{
10
    private const KEY = 'invalidation';
11
12
    /**
13
     * @internal
14
     *
15
     * @param \Redis|\RedisCluster $redis
16
     */
17
    public function __construct(private $redis)
18
    {
19
    }
20
21
    public function store(array $tags): void
22
    {
23
        $this->redis->sAdd(self::KEY, ...$tags);
0 ignored issues
show
Bug introduced by
$tags is expanded, but the parameter $value1 of RedisCluster::sAdd() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
        $this->redis->sAdd(self::KEY, /** @scrutinizer ignore-type */ ...$tags);
Loading history...
24
    }
25
26
    public function loadAndDelete(): array
27
    {
28
        /** @var array{0: list<string>, 1: mixed} $values */
29
        $values = $this // @phpstan-ignore-line - PhpStan does not understand redis multi
30
            ->redis
31
            ->multi()
32
                ->sMembers(self::KEY)
33
                ->del(self::KEY)
34
            ->exec();
35
36
        return $values[0];
37
    }
38
}
39