Completed
Branch 2.x (b1c655)
by Julián
07:53
created

Memcached::close()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * sessionware (https://github.com/juliangut/sessionware).
5
 * PSR7 session management middleware.
6
 *
7
 * @license BSD-3-Clause
8
 * @link https://github.com/juliangut/sessionware
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
namespace Jgut\Middleware\Sessionware\Handler;
13
14
/**
15
 * Memcached session handler.
16
 */
17
class Memcached implements Handler
18
{
19
    use HandlerTrait;
20
21
    /**
22
     * @var \Memcached
23
     */
24
    protected $driver;
25
26
    /**
27
     * Memcached session handler constructor.
28
     *
29
     * @param \Memcached $driver
30
     */
31
    public function __construct(\Memcached $driver)
32
    {
33
        $this->driver = $driver;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     *
39
     * @throws \RuntimeException
40
     */
41
    public function open($savePath, $sessionName)
42
    {
43
        $this->testConfiguration();
44
45
        return true;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function close()
52
    {
53
        return true;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function read($sessionId)
60
    {
61
        return $this->driver->get($sessionId) ?: '';
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function write($sessionId, $sessionData)
68
    {
69
        return $this->driver->set($sessionId, $sessionData, time() + $this->configuration->getLifetime());
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function destroy($sessionId)
76
    {
77
        return $this->driver->delete($sessionId);
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     *
83
     * @SuppressWarnings(PMD.ShortMethodName)
84
     */
85
    public function gc($maxLifetime)
86
    {
87
        return true;
88
    }
89
}
90