Completed
Push — master ( c385cb...b0036f )
by Wei
04:12
created

RedisCacheProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

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