#key-value-database #embedded-database #rocksdb #redis #binary-heap #kv #nosql

redis_rocksdb

rust implement structure kv(key/value) embedded database, storage by rocksdb

1 unstable release

0.3.9 Apr 11, 2024
0.3.8 Oct 5, 2023
0.3.6 Feb 18, 2023
0.3.4 Jan 29, 2023
0.1.1 Mar 7, 2022

#554 in Database interfaces

Download history 8/week @ 2024-09-22 2/week @ 2024-09-29

530 downloads per month

Apache-2.0

165KB
4K SLoC

redis_rocksdb

rust implement structure kv(key/value) embedded database, storage by rocksdb
Feature list

  1. redis list
  2. Object, key+field
  3. ObjectBit, a bit object
  4. Max/Min binary heap(zero copy)
  5. B + Tree (Binary plus Tree) ...

Sample

more details see the test
Max Heap

use rocksdb::TransactionDB;
use redis_rocksdb::{Heap, RedisRocksdb, WrapTransactionDB};

fn sample(){
    let trans_db= TransactionDB::open_default("db_name.db").expect("");
    let redis_db = RedisRocksdb::new(trans_db);
    let wrap_db = WrapTransactionDB { db: redis_db.get_db() };

    let max_heap = RedisRocksdb::max_heap();
    let key = vec![0 as u8, 1, 2];
    let field = vec![6 as u8, 7, 8];
    let value = "data".to_owned();

    let _ = max_heap.push(&wrap_db, &field, value.as_bytes());
    let _ = max_heap.pop(&wrap_db, &key);
}

Object

use rocksdb::TransactionDB;
use redis_rocksdb::{Heap, Object, RedisRocksdb, WrapTransactionDB};

fn sample(){
    let trans_db= TransactionDB::open_default("db_name.db").expect("");
    let redis_db = RedisRocksdb::new(trans_db);
    let wrap_db = WrapTransactionDB { db: redis_db.get_db() };

    let object = RedisRocksdb::object();
    let key = vec![0 as u8, 1, 2];
    let field = vec![6 as u8, 7, 8];
    let value = "data".to_owned();

    let _ = object.set(&wrap_db, &field, value.as_bytes());
    let _ = object.get(&wrap_db, &key, &field);
}

Install

Window

  1. install llvm
  2. Environment value: set LIBCLANG_PATH=E:/lang/LLVM/lib --- sometimes need to restart the window system for clion

Linux

See:

ssdb-rocks(c++)
ssdb
rust-rocksdb, no transaction
ckb-rocksdb, transaction

注:在v0.1.0版本时使用ckb-rocksdb,在v0.2.0版本中,为了减少一次函数调用,把事务与非事务分别使用不同的接口实现,所以就没有必要再使用ckb-rocksdb

Dependencies

~24–34MB
~594K SLoC