您好,欢迎访问一九零五行业门户网

SSDB Redis替代品

ssdb是一个快速的用来存储十亿级别列表数据的开源 nosql 数据库。项目地址:https://github.com/ideawu/ssdbhttp://ssdb.io/ 特性 替代 redis 数据库, redis 的 100 倍容量 leveldb 网络支持, 使用 c/c++ 开发 redis api 兼容, 支持 redis 客户端 适合存储集
ssdb是一个快速的用来存储十亿级别列表数据的开源 nosql 数据库。项目地址:https://github.com/ideawu/ssdbhttp://ssdb.io/特性替代 redis 数据库, redis 的 100 倍容量 leveldb 网络支持, 使用 c/c++ 开发 redis api 兼容, 支持 redis 客户端 适合存储集合数据, 如 list, hash, zset... 客户端 api 支持的语言包括: c++、php、python、cpy、java、nodejs、ruby、go。 持久化的队列服务 主从复制, 负载均衡性能1000请求:writeseq : 0.546 ms/op 178.7 mb/swriterand : 0.519 ms/op 188.1 mb/sreadseq : 0.304 ms/op 321.6 mb/sreadrand : 0.310 ms/op 315.0 mb/s
并发:========== set ==========qps: 44251, time: 0.226 s========== get ==========qps: 55541, time: 0.180 s========== del ==========qps: 46080, time: 0.217 s========== hset ==========qps: 42338, time: 0.236 s========== hget ==========qps: 55601, time: 0.180 s========== hdel ==========qps: 46529, time: 0.215 s========== zset ==========qps: 37381, time: 0.268 s========== zget ==========qps: 41455, time: 0.241 s========== zdel ==========qps: 38792, time: 0.258 s
在macbook pro 13 (retina屏幕)上运行。与redis的比较:性能数据使用 ssdb-bench(ssdb) 和 redis-benchmark(redis) 来获取。架构安装下载压缩包,解压缩wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zipunzip mastercd ssdb-master
编译make
安装(可选)sudo make install
运行./ssdb-server ssdb.conf
或者以后台的方式运行./ssdb-server -d ssdb.conf
ssdb命令行./tools/ssdb-cli -p 8888
停止ssdb-serverkill `cat ./var/ssdb.pid`
使用phpgetmessage());}$ret = $ssdb->set('key', 'value');if($ret === false){ // error!}echo $ssdb->get('key');
python使用pyssdb>>> import pyssdb>>> c = pyssdb.client()>>> c.set('key', 'value')1>>> c.get('key')'value'>>> c.hset('hash', 'item', 'value')1>>> c.hget('hash', 'item')'value'>>> c.hget('hash', 'not exist') is nonetrue>>> c.incr('counter')1>>> c.incr('counter')2>>> c.incr('counter')3>>> c.keys('a', 'z', 1)['counter']>>> c.keys('a', 'z', 10)['counter', 'key']
ruby使用ssdb-rbrequire ssdbssdb = ssdb.new url: ssdb://1.2.3.4:8889ssdb.set(mykey, hello world)# => truessdb.get(mykey)# => hello worldssdb.batch do ssdb.set foo, 5 ssdb.get foo ssdb.incr fooend# => [true, 5, 6]
gopackage mainimport ( fmt os ./ssdb )func main(){ ip := 127.0.0.1; port := 8888; db, err := ssdb.connect(ip, port); if(err != nil){ os.exit(1); } var val interface{}; db.set(a, xxx); val, err = db.get(a); fmt.printf(%s\n, val); db.del(a); val, err = db.get(a); fmt.printf(%s\n, val); db.do(zset, z, a, 3); db.do(multi_zset, z, b, -2, c, 5, d, 3); resp, err := db.do(zrange, z, 0, 10); if err != nil{ os.exit(1); } if len(resp) % 2 != 1{ fmt.printf(bad response); os.exit(1); } fmt.printf(status: %s\n, resp[0]); for i:=1; ingx_lua使用lua-resty-ssdblua_package_path /path/to/lua-resty-ssdb/lib/?.lua;;;server { location /test { content_by_lua ' local ssdb = require resty.ssdb local db = ssdb:new() db:set_timeout(1000) -- 1 sec local ok, err = db:connect(127.0.0.1, 8888) if not ok then ngx.say(failed to connect: , err) return end ok, err = db:set(dog, an animal) if not ok then ngx.say(failed to set dog: , err) return end ngx.say(set result: , ok) local res, err = db:get(dog) if not res then ngx.say(failed to get dog: , err) return end if res == ngx.null then ngx.say(dog not found.) return end ngx.say(dog: , res) db:init_pipeline() db:set(cat, marry) db:set(horse, bob) db:get(cat) db:get(horse) local results, err = db:commit_pipeline() if not results then ngx.say(failed to commit the pipelined requests: , err) return end for i, res in ipairs(results) do if type(res) == table then if not res[1] then ngx.say(failed to run command , i, : , res[2]) else -- process the table value end else -- process the scalar value end end -- put it into the connection pool of size 100, -- with 0 idle timeout local ok, err = db:set_keepalive(0, 100) if not ok then ngx.say(failed to set keepalive: , err) return end -- or just close the connection right away: -- local ok, err = db:close() -- if not ok then -- ngx.say(failed to close: , err) -- return -- end '; }}
c++#include #include #include #include #include ssdb.hint main(int argc, char **argv){ const char *ip = (argc >= 2)? argv[1] : 127.0.0.1; int port = (argc >= 3)? atoi(argv[2]) : 8888; ssdb::client *client = ssdb::client::connect(ip, port); if(client == null){ printf(fail to connect to server!\n); return 0; } ssdb::status s; s = client->set(k, hello ssdb!); if(s.ok()){ printf(k = hello ssdb!\n); }else{ printf(error!\n); } delete client; return 0;}
原文地址:ssdb redis替代品, 感谢原作者分享。
其它类似信息

推荐信息