2025-01-21 14:24:04 +08:00
# Nim-RocksDb
2018-01-27 11:34:54 +01:00
2018-09-04 23:02:57 -06:00
[")](https://travis-ci.org/status-im/nim-rocksdb)
[")](https://ci.appveyor.com/project/nimbus/nim-rocksdb)
[](https://opensource.org/licenses/Apache-2.0)
[](https://opensource.org/licenses/MIT)

2018-01-27 11:34:54 +01:00
A Nim wrapper for [Facebook's RocksDB ](https://github.com/facebook/rocksdb ), a persistent key-value store for Flash and RAM Storage.
2018-01-27 17:01:14 +01:00
## Current status
2025-01-21 14:24:04 +08:00
Nim-RocksDb provides a wrapper for the low-level functions in the librocksdb c
library.
2018-01-27 17:01:14 +01:00
2024-07-03 23:46:42 +08:00
## Installation
2018-12-25 11:56:20 +01:00
2025-01-21 14:24:04 +08:00
Nim-RocksDb requires Nim and the Nimble package manager. For Windows you will
need Visual Studio 2015 Update 3 or greater with the English language pack.
2018-12-25 11:56:20 +01:00
2024-07-03 23:46:42 +08:00
To get started run:
```
2025-01-21 14:24:04 +08:00
nimble install rocksdb
2024-07-03 23:46:42 +08:00
```
2018-01-27 17:01:14 +01:00
2025-01-21 14:24:04 +08:00
This will download and install the RocksDB libraries for your platform and copy
them into the `build/` directory of the project. On Linux and MacOS only static
linking to the RocksDb libraries is supported and on Windows only dynamic linking
is supported.
2024-07-03 23:46:42 +08:00
2025-01-21 14:24:04 +08:00
On Windows you may want to copy the dll into another location or set your PATH
to include the `build/` directory so that your application can find the dll on
startup.
2018-01-27 17:01:14 +01:00
2025-01-21 14:24:04 +08:00
### Compression libraries
2022-03-22 10:02:39 +01:00
2025-01-21 14:24:04 +08:00
RocksDb supports using a number of compression libraries. This library builds
and only supports the following compression libraries:
- lz4
- zstd
On Linux and MacOS these libraries are staticly linked into the final binary
along with the RocksDb static library. On Windows they are staticly linked into
the RocksDb dll.
### Static linking
2024-07-03 23:46:42 +08:00
2025-01-21 14:24:04 +08:00
On Linux and MacOS your Nim program will need to use the C++ linker profile
because RocksDb is a C++ library. For example:
2022-03-22 10:02:39 +01:00
2024-07-03 23:46:42 +08:00
```
2025-01-21 14:24:04 +08:00
when defined(macosx):
switch("clang.linkerexe", "clang++")
when defined(linux):
switch("gcc.linkerexe", "g++")
2022-03-22 10:02:39 +01:00
```
2025-01-21 14:24:04 +08:00
Note that static linking is currently not supported on windows.
2022-03-22 10:02:39 +01:00
2024-07-03 23:46:42 +08:00
## Usage
2024-06-12 21:16:06 +08:00
2024-07-03 23:46:42 +08:00
See [simple_example ](examples/simple_example.nim )
2024-06-12 21:16:06 +08:00
2018-01-27 11:34:54 +01:00
### Contribution
2025-01-21 14:24:04 +08:00
Any contribution intentionally submitted for inclusion in the work by you shall
be dual licensed as above, without any additional terms or conditions.
2018-09-04 23:02:57 -06:00
2025-01-10 13:41:01 +08:00
## Versioning
2025-01-21 14:24:04 +08:00
The library generally follows the upstream RocksDb version number, adding one
more number for tracking changes to the Nim wrapper itself.
2025-01-10 13:41:01 +08:00
2018-09-04 23:02:57 -06:00
## License
2019-01-03 14:04:11 +01:00
### Wrapper License
This repository is licensed and distributed under either of
2018-09-05 12:48:31 -06:00
* MIT license: [LICENSE-MIT ](LICENSE-MIT ) or http://opensource.org/licenses/MIT
2019-01-02 14:57:34 +01:00
or
* Apache License, Version 2.0, ([LICENSE-APACHEv2 ](LICENSE-APACHEv2 ) or http://www.apache.org/licenses/LICENSE-2.0)
2018-09-04 23:02:57 -06:00
2025-01-21 14:24:04 +08:00
at your option. This file may not be copied, modified, or distributed except
according to those terms.
2019-01-03 14:04:11 +01:00
### Dependency License
RocksDB is developed and maintained by Facebook Database Engineering Team.
It is built on earlier work on LevelDB by Sanjay Ghemawat (sanjay@google .com)
and Jeff Dean (jeff@google .com)
RocksDB is dual-licensed under both the [GPLv2 ](https://github.com/facebook/rocksdb/blob/master/COPYING ) and Apache License, Version 2.0, ([LICENSE-APACHEv2 ](LICENSE-APACHEv2 ) or http://www.apache.org/licenses/LICENSE-2.0). You may select, at your option, one of the above-listed licenses.