Total Complexity | 9 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 38.1% |
Changes | 0 |
1 | <?php |
||
8 | class SessionCache { |
||
9 | private $session; |
||
10 | const ENTRY_KEY="_session_cache"; |
||
11 | |||
12 | 1 | public function __construct(){ |
|
13 | 1 | $this->session=new USession(); |
|
14 | 1 | $this->session->start(); |
|
15 | 1 | } |
|
16 | |||
17 | public function fetch($key) { |
||
18 | return $this->session->get($this->getEntryKey($key)); |
||
19 | } |
||
20 | |||
21 | public function clear() { |
||
22 | foreach($_SESSION as $k=>$notUsed){ |
||
23 | if(UString::startswith($k, self::ENTRY_KEY.".")){ |
||
24 | unset ( $_SESSION [$k] ); |
||
25 | } |
||
26 | } |
||
27 | } |
||
28 | |||
29 | 1 | public function exists($key) { |
|
30 | 1 | return $this->session->exists($this->getEntryKey($key)); |
|
31 | } |
||
32 | |||
33 | 1 | public function getEntryKey($key) { |
|
34 | 1 | return self::ENTRY_KEY.'.'.$key; |
|
35 | } |
||
36 | |||
37 | public function store($key, $object) { |
||
38 | $key=$this->getEntryKey($key); |
||
39 | $this->session->set($key, $object); |
||
40 | } |
||
41 | |||
42 | |||
43 | public function remove($key) { |
||
45 | } |
||
46 | } |
||
47 | |||
48 |