Reveldb 介绍
reveldb 一个基于 google leveldb 的 NoSQL
数据服务器,网络连接采用了 libevent 的 HTTP 接口,因此 reveldb 天生就适合处理 HTTP 请求。但更确切地说,reveldb
并没有直接采用 libevent 的 HTTP 接口,而是使用了另外一个基于 libevent 的网络连接库
libevhtp(https://github.com/ellzey/libevhtp),并对它做了适当的修改,使之成为
reveldb 的底层组件
evhttpx(https://github.com/forhappy/reveldb/tree/master/src/evhttpx),
evhttpx 为 reveldb 提供了 HTTP 和 HTTPS 支持,因此,reveldb 除了能够处理 HTTP 请求外,也能够处理 HTTPS
请求,这一特性是 Kyoto Tycoon 没有的。
Reveldb 定位于 Kyoto Tycoon 类似,也是一个数据库网络层的服务,具体一点就是 Leveldb 的网络层接口(因为 leveldb
本身只是一个程序库,并没有服务器/客户端的概念),reveldb 封装了 leveldb 的绝大部分操作,如 Snapshot, Writebatch,
Iterator 等等,并且在此基础之上扩展了很多命令,比如 string 的 append, prepend, insert,Key-Value 的
mset, mget, mdel, seize, mseize,此外还有 range query, 基于编辑距离的查找,正则式 regex
匹配查找;同时还提供了一些数据库管理的命令,如compact, repair, destroy 等;Ling外,reveldb
支持打开多个数据库,底层使用了红黑树缓存各个客户端已经打开的 leveldb 实例。
HTTP RPC 示例:
/rpc/echo
-
Description: Echo back the input data as the output data, as well as HTTP headers, just for testing.
-
input: (optional): arbitrary records.
-
output: (optional): corresponding records to the input data.
-
status code: 200.
-
sample request:
http://127.0.0.1:8088/rpc/echo?db=default&key=hello&value=world
-
sample response:
{ "code": 200, "status": "OK", "message": "Reveldb echoed the HTTP headers and query arguments of your request.", "date": "Mon, 17 Dec 2012 12:50:22 GMT", "request": { "headers": { "Host": "127.0.0.1:8088", "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:17.0) Gecko/20100101 Firefox/17.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive" }, "arguments": { "db": "default", "key": "hello", "value": "world" } }
}
/rpc/set
-
Description:
-
input: db: the database identifier.
-
input: key: key to be added.
-
input: value: value along with the key to be added.
-
status code: 200.
-
sample request:
http://127.0.0.1:8088/rpc/set?db=hello&key=hello&value=world
-
sample response:
{ "code": 200, "status": "OK", "message": "Set key-value pair done.", "date": "Thu, 27 Dec 2012 09:11:26 GMT"
}
/rpc/get
-
Description:
-
input: db: the database identifier.
-
input: key: which key to get.
-
status code: 200.
-
sample request:
http://127.0.0.1:8088/rpc/get&db=hello&key=hello
-
sample response:
-
{
“code”: 200,
“status”: “OK”,
“message”: “Get key-value pair done.”,
“date”: “Thu, 27 Dec 2012 09:19:05 GMT”,
“kv”: {
“hello”: “worldworld”
}
}
Reveldb 官网
https://github.com/forhappy/reveldb
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。