方法參考:http://www.cnblogs.com/zgaspnet/p/3939198.htmlphp
簡單回顧redis的四種數據類型 a.string:最簡單的數據類型 1. set user:001:name lijie 2. set user:001:age 20 b.hash:能夠當作表,hash table,比string速度快 1. hset user:001 name lamp age 20 2. hset user:001 sex nan 3. hset user:002 name lijie age 20 4. hgetall user:001 c.list:棧、隊列 d.set:並集、交集、差集 e.zset:set升級版,多了一個順序
<?php //實例化 $redis = new Redis(); //鏈接服務器 $redis->connect("localhost"); //受權 $redis->auth("lamplijie"); //相關操做 $redis->set("name","lampbrother"); $data = $redis->key("*"); var_dump($data);
輸出:array(1) { [0]=> string(4) "name" } html