ds_append ds_incrby
storage#%E6%96%B0%E5%A2%9E%E5%8A%A0%E7%B1%BB%E4%BC%BCredis%E7%9A%84hashs%E5%8A%9F%E8%83%BD%E7%94%A8%E6%B3%95%E4%B8%80%E6%A0%B7)新增加类似redis的hashs功能,用法一样
ds_hdel ds_hget ds_hset ds_hmget ds_hmset ds_hincrby ds_hgetall
storage)安装 redis-storage
https://github.com/qiye/redis-storage 获取源码 make init make MALLOC=tcmalloc_minimal 这一步需要root权限 make install PREFIX=/usr/local/redis
storage#%E4%BF%AE%E6%94%B9redis%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6)修改redis配置文件
ds:create_if_missing 1 //if the specified database didn't exist will create a new one ds:error_if_exists 0 //if the opened database exsits will throw exception ds:paranoid_checks 0 ds:block_cache_size 10000 ds:write_buffer_size 100000000 //写缓存大小 ds:block_size 4096 ds:max_open_files 8000 //leveldb最多可以使用的檔案數,一個檔案可以儲存 2MB 的資料。 ds:block_restart_interval 16 ds:path /usr/local/redis/db/leveldb //leveldb save path
cmd-%E7%94%A8%E6%B3%95%E8%B7%9Fredis%E7%9A%84%E4%B8%80%E6%A0%B7)redis new cmd 用法跟redis的一样
ds_append ds_incrby ds_hdel ds_hget ds_hset ds_hmget ds_hmset ds_hincrby ds_hgetall ds_set name qiye ds_get name ds_del name ds_mset key value age 20 ds_mget key age ds_del key age rl_set name shenzhe //先把数据存到leveldb,再存到redis rl_get name //先尝试从redis取数据,如没取到,再尝试从redis取数据 rl_del name //先从leveldb删除数据,再从redis删除数据
//php code include "redis.php"; $db = new redis("127.0.0.1", 6379); $rc = $db->connect(); if(!$rc) { echo "can not connect redis server\r\n"; exit; } $data = $db->multi(array('DEL test', 'SET test 1', 'GET test')); print_r($data); echo $db->set("name", "qiye"); echo $db->get("name"); $db->ds_set("name", "qiye"); $db->ds_set("age", "20"); $data = $db->ds_mget( "name", "age"); print_r($data);
storage#php%E5%BC%80%E5%8F%91%E8%80%85%E6%8E%A8%E8%8D%90%E4%BD%BF%E7%94%A8-phpredis-%E5%8A%A0%E5%BC%BA%E7%89%88-%E4%B8%93%E9%97%A8%E9%92%88%E5%AF%B9redis- storage%E7%9A%84php%E6%89%A9%E5%B1%95)php开发者推荐使用 phpredis 加强版 专门针对redis- storage的php扩展
地址: https://github.com/shenzhe/phpredis
$redis->dsSet("name", "shenzhe"); //把数据存到leveldb $redis->dsGet("name"); //从leveldb取出数据, 输出 shenzhe $redis->dsMSet(array("daniu"=>"qiye","cainiao"=>"shenzhe")); //批量把数据存到leveldb; keys结构 array("key1"=>"val1", "key2"=>"val2") $redis->dsMGet(array("qiye", "cainiao")); //批量从leveldb取出数据 $redis->dsDel("name"); //从leveldb删除数据, $key可以是字符串,也可是key的数组集合(相当于批量删除) $redis->dsDel(array("daniu","cainiao")); //从leveldb删除数据, $key可以是字符串,也可是key的数组集合(相当于批量删除) $redis->rlSet("name", "zeze"); //先把数据存到leveldb,再存到redis $redis->rlGet("name"); $redis->get("name"); $redis->dsGet("name"); $redis->rlDel("name");