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 }