<?PHP$redis=NewRedis ();$redis->connect (' 127.0.0.1 ', 6379);$redis->auth (' 123456 ');//string$redis->set (' Test ', ' HelloWorld ');$get=$redis->get (' Test ');//HelloWorld$tt=$redis->del (' Test ');//Int (1) Returns the number of successes//list$redis->delete (' List-key '); $redis->rpush (' List-key ', ' item ');//push in from the right side$redis->rpush (' List-key ', ' item2 ');$redis->rpush (' List-key ', ' item ');$redis->rpush (' List-key ', ' item3 ');$lRange=$redis->lrange (' List-key ', 0,-1);//Remove the specified range//array (4) {[0]=> string (4) "Item" [1]=> string (5) "Item2" [2]=> string (4) "Item" [3]=> string (5) "Item3"}$lIndex=$redis->lindex (' List-key ', 1);//Remove the specified element//string (4) "Item2"$lPop=$redis->lpop (' List-key ');//Pop -up from the left side does not exist in the list//string (4) "Item"$lRange 2=$redis->lrange (' List-key ', 0,-1);//Remove the specified range//array (2) {[0]=> string (5) "Item2" [1]=> string (5) "Item3"}//sadd$redis->sadd (' Set-key ', ' item ');$redis->sadd (' Set-key ', ' item2 ');$redis->sadd (' Set-key ', ' item3 ');$redis->sadd (' Set-key ', ' item ');//The collection is not allowed to have the same element otherwise it will overwrite$smembers=$redis->smembers (' Set-key ');//Get all elements//array (3) {[0]=> string (5) "Item2" [1]=> string (5) "Item3" [2]=> string (4) "Item"}$sismember=$redis->sismember (' Set-key ', ' item4 ');//checks if an element exists in the collection//bool (false)$srem=$redis->srem (' Set-key ', ' item2 ');//removes the element from the collection//int (1) Returns the number of successes//hash$redis->hset (' Hash-key ', ' sub-key1 ', ' value1 ');//Int (1) Returns the number of successes$redis->hset (' Hash-key ', ' sub-key2 ', ' value1 ');//Int (1) Returns the number of successes$redis->hset (' Hash-key ', ' sub-key1 ', ' value1 ');//Int (0) already exists$hgetall=$redis->hgetall (' Hash-key ');//Array (2) {["Sub-key1"]=> string (6) "value2" ["Sub-key2"]=> string (6) "Value1"}$redis->hdel (' Hash-key ', ' Sub-key2 ');//Int (1) Returns the number of successes$redis->hdel (' Hash-key ', ' Sub-key2 ');//Int (0) does not exist return 0$hget=$redis->hget (' Hash-key ', ' sub-key1 ');//string (6) "Value1"$hgetall 2=$redis->hgetall (' Hash-key ');//Array (1) {["Sub-key1"]=> string (6) "Value1"}//zset$redis->zadd (' Zset-key ', 728, ' member1 ');//Int (1) Returns the number of successes$redis->zadd (' Zset-key ', 982, ' Member0 ');//Int (1) Returns the number of successes$redis->zadd (' Zset-key ', 982, ' Member0 ');//Int (0) already exists$zrange=$redis->zrange (' Zset-key ', 0,1, ' withscores ');//Array (2) {["Member1"]=> float (728) ["Member0"]=> float (982)}?>
Redis actual PHP instance "1"