Completed
Push — master ( 5c8a13...04755b )
by Novikov
01:34
created

MemcachedProvider::remove()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace NV\RequestLimitBundle\Storage\Provider;
4
5
class MemcachedProvider implements ProviderInterface
6
{
7
    /**
8
     * @var \Memcached $_memcached
9
     */
10
    private $_memcached;
11
12
    /**
13
     * @param $configuration
14
     */
15
    public function configure($configuration)
16
    {
17
        $memcachedHost = $configuration['server'];
18
        $memcachedPort = $configuration['port'];
19
20
        $_memcached = new \Memcached();
21
        $_memcached->addServer($memcachedHost, $memcachedPort);
22
        $this->_memcached = $_memcached;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function get($key)
29
    {
30
       return $this->_memcached->get($key);
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function set($key, $expiresAt)
37
    {
38
        return $this->_memcached->set($key, $expiresAt, 60 * 60 * 24 * 30);
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    public function remove($key)
45
    {
46
        return $this->_memcached->delete($key);
47
    }
48
49
    /**
50
     * @return array
51
     */
52
    public function fetchAllItems()
53
    {
54
        return $this->_memcached->fetchAll();
55
    }
56
57
    /**
58
     * @return int
59
     */
60
    public function getItemsCount()
61
    {
62
        return count($this->_memcached->fetchAll());
63
    }
64
}
65