RedisSessionHandler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 43
rs 10
c 1
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A open() 0 4 1
A close() 0 4 1
A read() 0 6 1
A write() 0 9 1
A destroy() 0 8 1
A gc() 0 4 1
1
<?php
2
3
namespace cvweiss\projectbase;
4
5
class RedisSessionHandler implements \SessionHandlerInterface
6
{
7
    public function open($savePath, $sessionName)
8
    {
9
        return true;
10
    }
11
12
    public function close()
13
    {
14
        return true;
15
    }
16
17
    public function read($id)
18
    {
19
        $redis = Redis::get();
20
21
        return $redis->get("sess:$id");
22
    }
23
24
    public function write($id, $data)
25
    {
26
        $sessionTimeout = (int) Config::getInstance()->get("session_timeout", 3600);
27
        $redis = Redis::get();
28
29
        $redis->setex("sess:$id", $sessionTimeout, $data);
30
31
        return true;
32
    }
33
34
    public function destroy($id)
35
    {
36
        $redis = Redis::get();
37
38
        $redis->del("sess:$id");
39
40
        return true;
41
    }
42
43
    public function gc($maxlifetime)
44
    {
45
        return true;
46
    }
47
}
48