소스 검색

redis测试

caolongle 3 년 전
부모
커밋
1e7afaf7e0
2개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      app/controller/Index.php
  2. 8 0
      config/cache.php

+ 3 - 2
app/controller/Index.php

@@ -2,12 +2,13 @@
2 2
 namespace app\controller;
3 3
 
4 4
 use app\BaseController;
5
-
5
+use think\facade\Cache;
6 6
 class Index extends BaseController
7 7
 {
8 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 14
     public function hello($name = 'ThinkPHP6')

+ 8 - 0
config/cache.php

@@ -25,5 +25,13 @@ return [
25 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
 ];