All Projects → aleksandarskrbic → rocks4j

aleksandarskrbic / rocks4j

Licence: GPL-3.0 license
KV Store for Java backed by RocksDB

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to rocks4j

Tendis
Tendis is a high-performance distributed storage system fully compatible with the Redis protocol.
Stars: ✭ 2,295 (+17553.85%)
Mutual labels:  rocksdb, kvstore
pbdb
A key/value database inspired by chapter 3 of Designing Data-Intensive Applications by Martin Kleppmann.
Stars: ✭ 25 (+92.31%)
Mutual labels:  kv-database, kv-store
toplingdb
ToplingDB is a cloud native LSM Key-Value Store with searchable compression algo and distributed compaction
Stars: ✭ 631 (+4753.85%)
Mutual labels:  rocksdb, kvstore
Kites
🪁 A consistency, partition tolerance completed distributed KV store, implementation of the Raft distributed consensus protocol and Kotlin.
Stars: ✭ 41 (+215.38%)
Mutual labels:  rocksdb, kvstore
kedis
Kedis-Server is a Redis-Protocol compatible persistance NoSQL with RocksDB as its storage engine
Stars: ✭ 82 (+530.77%)
Mutual labels:  rocksdb, kv-storage
blackwidow
A library implements REDIS commands(Strings, Hashes, Lists, Sorted Sets, Sets, Keys, HyperLogLog) based on rocksdb
Stars: ✭ 40 (+207.69%)
Mutual labels:  rocksdb
MIT6.824-2021
4 labs + 2 challenges + 4 docs
Stars: ✭ 594 (+4469.23%)
Mutual labels:  kvstore
xdagj
XDAGJ is an implementation of XDAG in Java. https://xdag.io
Stars: ✭ 81 (+523.08%)
Mutual labels:  rocksdb-java
newsql nosql library
整理12种数据库相关资料,mysql,mariaDB,Percona Server,MongoDB,Redis,RocksDB,TiDB,CouchDB,Cassandra,TokuDB,MemDB,Oceanbase
Stars: ✭ 270 (+1976.92%)
Mutual labels:  rocksdb
orbit-db-kvstore
Key-Value database for orbit-db
Stars: ✭ 24 (+84.62%)
Mutual labels:  kv-store
mirdb
MirDB: A Persistent Key-Value Store with Memcached protocol.
Stars: ✭ 75 (+476.92%)
Mutual labels:  kv-database
balboa
server for indexing and querying passive DNS observations
Stars: ✭ 42 (+223.08%)
Mutual labels:  rocksdb
RocksServer
Flexible and fast server for RocksDB
Stars: ✭ 33 (+153.85%)
Mutual labels:  rocksdb
gocache
High performance and lightweight in-memory cache library with LRU and FIFO support as well as memory-usage-based-eviction
Stars: ✭ 15 (+15.38%)
Mutual labels:  kvstore
Pomegranate
🌳 A tiny skiplist based log-structured merge-tree written in Rust.
Stars: ✭ 20 (+53.85%)
Mutual labels:  kvstore
rosedb
🚀 A high performance NoSQL database based on bitcask, supports string, list, hash, set, and sorted set.
Stars: ✭ 2,957 (+22646.15%)
Mutual labels:  kv-store
rippledb
Embeddable key-value database engine in pure TypeScript, based on LSM-Tree
Stars: ✭ 33 (+153.85%)
Mutual labels:  rocksdb
RHKeyValueStore
Key-Value storage tool, based on WCDB (WeChat DataBase).
Stars: ✭ 20 (+53.85%)
Mutual labels:  kvstore
pika
Pika is a nosql compatible with redis, it is developed by Qihoo's DBA and infrastructure team
Stars: ✭ 4,719 (+36200%)
Mutual labels:  rocksdb
reddit-pwa
Going Buildless: Simple Reddit PWA made with LitElement, Pika, import-maps and kv-storage.
Stars: ✭ 38 (+192.31%)
Mutual labels:  kv-storage

rocks4j

KV Store for Java backed by RocksDB.

Getting Started

Maven

<dependency>
  <groupId>com.github.aleksandarskrbic</groupId>
  <artifactId>rocks4j</artifactId>
  <version>1.0.0</version>
</dependency>

Gradle

compile "com.github.aleksandarskrbic:rocks4j:1.0.0"

Introduction

The goal of this project is to provide KV store backed by RocksDB with simple Java API. Allow developers to quickly integrate RocksDB into the existing Java/Scala project. It can be used as a local caching mechanism in microservices or just to replace huge in-memory data structures.

API

There are five available operations against KV repository:

  • save(K key, V value)
  • findByKey(K key)
  • findAll()
  • deleteByKey(K key)
  • deleteAll()

Examples

Suppose you have a Java class:

public class Item {
    private Long id;
    private String desc;
    
    // constructors, getters and setters
}

To create KV repository for Item class, firstly you need to create a configuration class that accepts a path to file (where RocksDB files will be) and the name of the repository:

final RocksDBConfiguration configuration = new RocksDBConfiguration("/path/to/rocksdb", "item");

After configuration class is created, you are able to instantiate the Item Repository:

public class ItemRepository extends RocksDBKeyValueRepository<Long, Item> {

  public ItemRepository(final RocksDBConfiguration configuration) {
    super(configuration);
  }
  
}
final ItemRepository itemRepository = new ItemRepository(configuration);
final Item item = new Item(1L, "Desc")
itemRepository.save(item.getId(), item);
final Optional<Item> itemOptional = itemRepository.findByKey(item.getId());
final Collection<Item> all = itemRepository.findAll();
itemRepository.deleteByKey(item.getId());
itemRepository.deleteAll();

Note

In order to maintain flexibility, when exception related to RocksDB or Serialization/Deserialization in RocksDBKeyValueRepository, exceptions are just propagated, so it's a client's responsibility to deal with it. Best practice would be to override methods from RocksDBKeyValueRepository and handle those exceptions and handle those exceptions into your repository class. Another solution would be to handle it every time you invoke methods provided by RocksDBKeyValueRepository which is not recommended.

Example

public static class ItemRepository extends RocksDBKeyValueRepository<Long, Item> {

    public ItemRepository(final RocksDBConfiguration configuration) {
        super(configuration);
    }

    @Override
    public void save(final Long key, final Item value) {
        try {
            super.save(key, value);
        } catch (final SerializationException e) {
            // log or handle
        } catch (final SaveFailedException e) {
            // log or handle
        }
    }

    // other methods
}

Credits

Special thanks to @jovicaandric and @vajda.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].