RedisCacheProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 20
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A clear() 0 2 1
A set() 0 4 1
A __construct() 0 2 1
A get() 0 2 1
1
<?php
2
/**
3
 * RedisCacheProvider
4
 *
5
 * @license MIT
6
 * @author zhangv
7
 */
8
namespace zhangv\wechat\pay\cache;
9
class RedisCacheProvider implements CacheProvider{
10
	/** @var Redis */
11
	private $redis = null;
12
13 2
	public function __construct($redis = null){
14 2
		$this->redis = $redis;
15 2
	}
16
17 1
	public function set($key,$jsonobj,$expireAt){
18 1
		$data = $jsonobj;
19 1
		$data->expires_at = $expireAt;
20 1
		$this->redis->set($key, json_encode($data));
21 1
	}
22
23 2
	public function get($key){
24 2
		return $this->redis->get($key);
25
	}
26
27 1
	public function clear($key){
28 1
		$this->redis->delete($key);
29
	}
30
}