SSDB --- queue实现

SSDB介绍

SSDB是一款nosql数据库,使用leveldb作为存储引擎,支持众多的数据结构,如 queue、zset和hash,宣称可用来替代redis,看来性能不可小觑。其作者是位国人,曾在360游戏部门任职过。SSDB被很多知名公司使用,代码质量不错。
http://ssdb.io/zh_cn/,代码托管在github。

queue的实现

leveldb本身是k/v数据库,如何在单纯的k/v上实现queue呢?
来看ssdb中的实现:
下面是ssdb/src/ssdb/ssdb.h 中queue部分的接口

    virtual int64_t qsize(const Bytes &name) = 0;
    // @return 0: empty queue, 1: item peeked, -1: error
    virtual int qfront(const Bytes &name, std::string *item) = 0;
    // @return 0: empty queue, 1: item peeked, -1: error
    virtual int qback(const Bytes &name, std::string *item) = 0;
    // @return -1: error, other: the new length of the queue
    virtual int64_t qpush_front(const Bytes &name, const Bytes &item, char log_type=BinlogType::SYNC) = 0;
    virtual int64_t qpush_back(const Bytes &name, const Bytes &item, char log_type=BinlogType::SYNC) = 0;
    // @return 0: empty queue, 1: item popped, -1: error
    virtual int qpop_front(const Bytes &n
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值