Passed
Push — master ( 4007a9...f8b95d )
by Liam
56s queued 11s
created

Redis::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 12
rs 9.9666
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Redis implementation for php-hystrix.
5
 *
6
 * PHP version 7.2
7
 *
8
 * @category Adapter
9
 * @package  Storage
10
 * @author   Liam Sorsby <[email protected]>
11
 * @license  https://www.apache.org/licenses/LICENSE-2.0 Apache
12
 * @link     https://github.org/liamsorsby/php-hystrix
13
 *
14
 * For the full copyright and license information, please view the LICENSE file.
15
 */
16
17
namespace liamsorsby\Hystrix\Storage\Adapter;
18
19
use Cache\Adapter\Redis\RedisCachePool;
20
21
/**
22
 * Class Redis
23
 *
24
 * @category Adapter
25
 * @package  Storage
26
 * @author   Liam Sorsby <[email protected]>
27
 * @license  https://www.apache.org/licenses/LICENSE-2.0 Apache
28
 * @link     https://github.org/liamsorsby/php-hystrix
29
 */
30
class Redis extends AbstractStorage
31
{
32
    /**
33
     * {@inheritDoc}
34
     *
35
     * @param array $options Options required to create the storage instance
36
     *
37
     * @return void
38
     */
39
    public function create(array $options): void
40
    {
41
        $redis = new \Redis();
42
        $redis->connect(
43
            $options['host'],
44
            $options['port'] ?? 6379,
45
            $options['timeout'] ?? 0.00,
46
            $options['reserved'] ?? null,
47
            $options['retryInterval'] ?? 0,
48
            $options['readTimeout'] ?? 0.00
49
        );
50
        $this->setStorage(new RedisCachePool($redis));
51
    }
52
}
53