/redis-storage

把leveldb嵌入到redis.实现真正的数据持久存储

Primary LanguageCBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

基于最新的redis-2.6.3开发的

用luajit替换LUA,增强lua性能
author: 七夜
QQ: 531020471
QQ群: 62116204(已满)
QQ群: 154249567 (未满)

email: lijinxing@gmail.com
blog:  www.cellphp.com 

https://github.com/qiye/redis-storage

1. download and install snappy
http://code.google.com/p/snappy/downloads/list
tar -zxvf snappy-1.0.5.tar.gz 
./configure --prefix=/usr/local/snappy
make && make install

2. download and install gperftools
http://code.google.com/p/gperftools/downloads/detail?name=gperftools-2.0.tar.gz&can=2&q=
tar -zxvf gperftools-2.0.tar.gz  
./configure --prefix=/usr/local/gperftools
make && make install

3. install leveldb
tar -jxvf RedisStorage-2.4.17.tar.bz2
cd RedisStorage-2.4.17/deps/leveldb
make

4. install redis
make


install finish

set redis.conf 

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

redis new cmd
ds_set name qiye
ds_get name
ds_del name 
ds_mset key value age 20
ds_mget key age
ds_del key age


cd php-hiredis/
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);