redis使用--tp5

參考教程:https://www.cnblogs.com/pyspang/p/11185759.html、

 

<?php
namespace app\index\controller;

use think\Cache;

class Index
{
    public function index()
    {
		 Cache::store('file')->set('file_test', 969);
		 Cache::store('file')->set('file_test2', 5656);
		 
       // phpinfo();
	  //方式一
	  Cache::store('redis')->set('test', array('k1'=>123));
	  $data = Cache::store('redis')->get('test');
	  var_dump($data);
	  
	  //方式二
	   $redis=new \Redis();
	   $redis->connect("127.0.0.1","6379");
	   $redis->set('name','33333');
	   echo $redis->get('name');
	   
		
	   
    }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章