@@ 18-44 (lines=27) @@ | ||
15 | private $redis; |
|
16 | private $pre; |
|
17 | ||
18 | public function __construct($configs = [], $dir = 'Cache:OpenOauth:') |
|
19 | { |
|
20 | parent::__construct($dir); |
|
21 | ||
22 | $this->pre = $this->cacheDir; |
|
23 | ||
24 | $config = $configs + ['host' => '127.0.0.1', 'port' => '6379', 'database' => '0', 'scheme' => 'tcp', 'auth' => null]; |
|
25 | ||
26 | ini_set('default_socket_timeout', 50);//socket连接超时时间; |
|
27 | ||
28 | $this->redis = new Client( |
|
29 | [ |
|
30 | 'scheme' => $config['scheme'], |
|
31 | 'host' => $config['host'], |
|
32 | 'port' => $config['port'], |
|
33 | ]); |
|
34 | ||
35 | if (!empty($config['auth'])) { |
|
36 | $this->redis->auth($config['auth']); |
|
37 | } |
|
38 | ||
39 | $this->redis->select($config['database']); |
|
40 | ||
41 | if (!$this->redis) { |
|
42 | exit('Redis初始化连接失败-cache'); |
|
43 | } |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * 根据缓存名获取缓存内容. |
@@ 18-44 (lines=27) @@ | ||
15 | private $redis; |
|
16 | private $pre; |
|
17 | ||
18 | public function __construct($configs = [], $dir = 'Database:OpenOauth:') |
|
19 | { |
|
20 | parent::__construct($dir); |
|
21 | ||
22 | $this->pre = $this->databaseDir; |
|
23 | ||
24 | $config = $configs + ['host' => '127.0.0.1', 'port' => '6379', 'database' => '0', 'scheme' => 'tcp', 'auth' => null]; |
|
25 | ||
26 | ini_set('default_socket_timeout', 50);//socket连接超时时间; |
|
27 | ||
28 | $this->redis = new Client( |
|
29 | [ |
|
30 | 'scheme' => $config['scheme'], |
|
31 | 'host' => $config['host'], |
|
32 | 'port' => $config['port'], |
|
33 | ]); |
|
34 | ||
35 | if (!empty($config['auth'])) { |
|
36 | $this->redis->auth($config['auth']); |
|
37 | } |
|
38 | ||
39 | $this->redis->select($config['database']); |
|
40 | ||
41 | if (!$this->redis) { |
|
42 | exit('Redis初始化连接失败-database'); |
|
43 | } |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * 根据缓存名获取缓存内容. |