TP5使用redis


 1 <?php
 2 namespace app\api\controller;
 3 use app\api\controller\Common_base;
 4 use think\cache\driver\Redis;
 5 
 6
 7 class a extends Common_base
 8 {
 9 
10     public function b(){
11         extract($_REQUEST);
12         if (!$a|| !$b) {
13             die(json_encode(array('result' => 'fail', 'msg' => 'fail')));
14         }
15         $key= $a."-".$b;
16         //redis參數
17         $options= [
18             'host'       => '127.0.0.1',
19             'port'       => 6379,
20             'password'   => 'xxxxx',
21             'select'     => 0,
22             'timeout'    => 0,
23             'expire'     => 0,
24             'persistent' => false,
25             'prefix'     => '',
26         ];
27         $redis=new Redis($options);//實例化redis
28         $handler = $redis->handler();//得到句柄
29         $handler->hDel('tasks',$key);
30         $handler->hDel('taskuptime',$key);
31         $handler->del($key);
32         die(json_encode(array('result' => 'success', 'msg' => 'success')));
33 
34     }
35 }

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM