https://github.com/zio/zio-rocksdb
A ZIO-based interface to RocksDB.
https://github.com/zio/zio-rocksdb
rocksdb scala zio
Last synced: 20 days ago
JSON representation
A ZIO-based interface to RocksDB.
- Host: GitHub
- URL: https://github.com/zio/zio-rocksdb
- Owner: zio
- License: apache-2.0
- Created: 2019-12-28T13:42:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-18T15:56:13.000Z (6 months ago)
- Last Synced: 2025-04-04T05:11:21.510Z (about 1 month ago)
- Topics: rocksdb, scala, zio
- Language: Scala
- Homepage: https://zio.dev/zio-rocksdb
- Size: 104 KB
- Stars: 32
- Watchers: 10
- Forks: 17
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-zio - zio-rocksdb - based interface to RocksDB. (NoSQL)
README
[![Project stage][Stage]][Stage-Page]
[![Release Artifacts][Badge-SonatypeReleases]][Link-SonatypeReleases]# zio-rocksdb
A ZIO-based interface to RocksDB.
## Installation
Add the following dependencies to your `build.sbt` file:
```scala
libraryDependencies ++= Seq(
"dev.zio" %% "zio-rocksdb" % ""
)
```## Using RocksDB
Use the provided `RocksDB` wrapper:
```scala
import java.nio.charset.StandardCharsetsimport zio.rocksdb
import zio.rocksdb.{ RocksDB }val UTF_8 = StandardCharsets.UTF_8
val key = "key".getBytes(UTF_8)
val value = "value".getBytes(UTF_8)val database = RocksDB.live("/data/state")
val readWrite = RocksDB.put(key, value) *> RocksDB.get(key)
val result = readWrite.provideCustomLayer(database)
```## Using TransactionDB
`zio-rocksdb` provides transactional capabilities using RocksDB [Transaction API].```scala
import java.nio.charset.StandardCharsetsimport zio.rocksdb
import zio.rocksdb.{ TransactionDB, Transaction }val key0 = "key0".getBytes(UTF_8)
val key1 = "key1".getBytes(UTF_8)
val value0 = "value0".getBytes(UTF_8)
val value1 = "value1".getBytes(UTF_8)val database = TransactionDB.live("/data/state")
val write0 = Transaction.put(key0, value0)
val write1 = Transaction.put(key1, value1)
val writeTogether = TransactionDB.atomically {
write0 <&> write1
}
val result = readWrite.provideCustomLayer(database)
```[Transaction API]: https://github.com/facebook/rocksdb/wiki/Transactions#transactiondb
## Getting help
Join us on the [ZIO Discord server](https://discord.gg/2ccFBr4).
## Legal
Copyright 2019 Itamar Ravid and the zio-rocksdb contributors. All rights reserved.
[Link-SonatypeReleases]: https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-rocksdb_2.12/ "Sonatype Releases"
[Badge-SonatypeReleases]: https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-rocksdb_2.12.svg "Sonatype Releases"
[Stage]: https://img.shields.io/badge/Project%20Stage-Development-yellowgreen.svg
[Stage-Page]: https://github.com/zio/zio/wiki/Project-Stages