Browse Source

使用redis作为缓存

liuzejian 1 year ago
parent
commit
248f992ff6

+ 1 - 1
config/cache.php

@@ -15,7 +15,7 @@ return [
     |
     */
 
-    'default' => env('CACHE_DRIVER', 'file'),
+    'default' => env('CACHE_DRIVER', 'redis'),
 
     /*
     |--------------------------------------------------------------------------

+ 1 - 1
modules/Channel/Http/Controllers/WechatOpenPlatformController.php

@@ -65,7 +65,7 @@ class WechatOpenPlatformController extends CatchController
         $componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
         myLog('authorCommand')->info('start:'. $component_appid);
         $app = WechatOpenPlatformService::buildApplication($componentInfo);
-        $app->setCache(new RedisAdapter(Redis::client()));
+        $app->setCache(app('cache.store'));
         $server = $app->getServer();
 
         $server->handleVerifyTicketRefreshed(function($message, \Closure $next) {

+ 9 - 0
tests/Channel/Http/Controllers/WechatOpenPlatformControllerTest.php

@@ -17,4 +17,13 @@ class WechatOpenPlatformControllerTest extends UsedTestCase
                 ['name' => '比利时联合银行股份有限公司', 'is_show' => 1, 'code' => 651],
             ], ['name'], ['is_show']);
     }
+    public function testauthorCommand()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/channel/openPlatform/authorCommand/wxf313b3506bac2647', [
+
+        ]);
+        $res->dump();
+    }
 }