class Redis extends BaseController { public function index(){ key 操作 p($r->exists("string")); p($r->rename("name5","namex")); //改key的name p($r->type("name6")); p($r->ttl("name5"));//过期时间 p($r->expire("name5","7900"));//指定过期时间 p($r->del("name1","name2","name3")); //删除 p($r->flushDB());//删除当前库 p($r->flushAll());//删除所有库 p($r->dbSize());//当前数量 p($r->select(0));//选择库 p($r->move("name7",1)); //移动key到另一个数据库 $r= $this->r; $r->set("string","value1"); // $r->mset(['mstring1'=>'mstring1',',string2'=>'mstring2']); p($r->get("string")); // p($r->get("mstring1")); p($r->lPush("list","班级1","班级2","班级3")); p($r->lrange('list',0,-1)); //返回全部数据,数组形式 echo "集合:<br>"; p($r->sAdd("list","list1","list2","list3")); p($r->sMembers("list")); p($r->hSet("hash","Hkey1","Hvalue1")); p($r->hSet("hash","Hkey2","Hvalue2")); p($r->hGetAll("hash")); p($r->zAdd('zYouxvJihe','100',"1")); p($r->zAdd('zYouxvJihe','300',"4")); p($r->zAdd('zYouxvJihe','400',"2")); p($r->zAdd('zYouxvJihe','200',"3")); p($r->zRangeByScore('zYouxvJihe','0','4')); for($i=1;$i<20000;$i++){ echo "<br>"; echo $r->get("key".$i); echo "<br>"; } $m =$this->m; $m->addServer(); //向连接池中添加一个memcache服务器 $m->set("aa","aaa",MEMCACHE_COMPRESSED,3600); $m->delete("aa"); //从服务端删除一个key $m->flush();//清洗删除已经存储的所有的key p($m->get("aa")); //获取key的值 $m->close(); $m = $this->m; $m->flush(); } public function mongo(){ $m = new MongoDBDriverManager("mongodb://localhost:27017"); p($m); } }