Browse Source

redis测试

caolongle 3 years ago
parent
commit
1e7afaf7e0
2 changed files with 11 additions and 2 deletions
  1. 3 2
      app/controller/Index.php
  2. 8 0
      config/cache.php

+ 3 - 2
app/controller/Index.php

@@ -2,12 +2,13 @@
2
 namespace app\controller;
2
 namespace app\controller;
3
 
3
 
4
 use app\BaseController;
4
 use app\BaseController;
5
-
5
+use think\facade\Cache;
6
 class Index extends BaseController
6
 class Index extends BaseController
7
 {
7
 {
8
     public function index()
8
     public function index()
9
     {
9
     {
10
-        echo phpinfo();
10
+        Cache::store('redis')->set("name","redis测试",3600);
11
+        echo Cache::store('redis')->get("name");
11
     }
12
     }
12
 
13
 
13
     public function hello($name = 'ThinkPHP6')
14
     public function hello($name = 'ThinkPHP6')

+ 8 - 0
config/cache.php

@@ -25,5 +25,13 @@ return [
25
             'serialize'  => [],
25
             'serialize'  => [],
26
         ],
26
         ],
27
         // 更多的缓存连接
27
         // 更多的缓存连接
28
+        'redis' => [
29
+            'type' => 'redis',
30
+            'expire' => 0,
31
+            'host' => '47.98.171.116',
32
+            'password' => '2821583Xy',
33
+            'port' => '6379',
34
+            'select' => '0',
35
+        ]
28
     ],
36
     ],
29
 ];
37
 ];