User Tools

Site Tools


learn:redis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
learn:redis [2017/03/06 07:23]
soup
learn:redis [2017/03/06 07:32] (current)
soup
Line 26: Line 26:
 <​code>​ <​code>​
 redis-cli redis-cli
 +keys * # listing all keys
 </​code>​ </​code>​
  
Line 37: Line 38:
 and may need reset php-fpm and may need reset php-fpm
  
 +PHP示例, set 和 list
 +<​code>​
 +
 +<?php
 +   //​连接本地的 Redis 服务
 +   ​$redis = new Redis();
 +   ​$redis->​connect('​127.0.0.1',​ 6379);
 +   echo "​Connection to server sucessfully";​
 +   //​设置 redis 字符串数据
 +   ​$redis->​set("​tutorial-name",​ "Redis tutorial souppppp"​);​
 +   // 获取存储的数据并输出
 +   echo "​Stored string in redis:: " . $redis->​get("​tutorial-name"​);​
 +?>
 +
 +<?php
 +   //​连接本地的 Redis 服务
 +   ​$redis = new Redis();
 +   ​$redis->​connect('​127.0.0.1',​ 6379);
 +   echo "​Connection to server sucessfully"​.PHP_EOL;​
 +   //​存储数据到列表中
 +   ​$redis->​lpush("​tutorial-list",​ "​Redis"​);​
 +   ​$redis->​lpush("​tutorial-list",​ "​Mongodb"​);​
 +   ​$redis->​lpush("​tutorial-list",​ "​Mysql"​);​
 +   // 获取存储的数据并输出
 +   ​$arList = $redis->​lrange("​tutorial-list",​ 0 ,5);
 +   echo "​Stored string in redis"​.PHP_EOL;​
 +   ​print_r($arList);​
 +?>
 +
 +</​code>​
  
 主要命令参考:​ 主要命令参考:​
learn/redis.1488784981.txt.gz · Last modified: 2017/03/06 07:23 by soup