RequestCache::put()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * This file is part of the bugloos/fault-tolerance-bundle project.
5
 * (c) Bugloos <https://bugloos.com/>
6
 * For the full copyright and license information, please view
7
 * the LICENSE file that was distributed with this source code.
8
 */
9
10
namespace Bugloos\FaultToleranceBundle\RequestCache;
11
12
use Bugloos\FaultToleranceBundle\RequestCache\Storage\StorageInterface;
13
14
/**
15
 * @author Mojtaba Gheytasi <[email protected]>
16
 */
17
class RequestCache
18
{
19
    private StorageInterface $storage;
20
21
    public function __construct(StorageInterface $storage)
22
    {
23
        $this->storage = $storage;
24
    }
25
26
    public function clearAll(string $commandKey): void
27
    {
28
        $this->storage->removeBucket($commandKey);
29
    }
30
31
    public function clear(string $commandKey, string $cacheKey): void
32
    {
33
        $this->storage->remove($commandKey, $cacheKey);
34
    }
35
36
    public function get(string $commandKey, string $cacheKey)
37
    {
38
        return $this->storage->get($commandKey, $cacheKey);
39
    }
40
41
    public function put(string $commandKey, string $cacheKey, $value, int $expiresAfterSeconds): void
42
    {
43
        $this->storage->set($commandKey, $cacheKey, $value, $expiresAfterSeconds);
44
    }
45
46
    public function exists(string $commandKey, string $cacheKey): bool
47
    {
48
        return $this->storage->exists($commandKey, $cacheKey);
49
    }
50
}
51