https://github.com/b1naryth1ef/rocksdb
A D binding for rocksdb
https://github.com/b1naryth1ef/rocksdb
binding rocksdb
Last synced: 12 months ago
JSON representation
A D binding for rocksdb
- Host: GitHub
- URL: https://github.com/b1naryth1ef/rocksdb
- Owner: b1naryth1ef
- Created: 2017-01-13T03:05:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-10T23:46:32.000Z (almost 8 years ago)
- Last Synced: 2025-01-10T21:24:36.853Z (over 1 year ago)
- Topics: binding, rocksdb
- Language: D
- Size: 22.5 KB
- Stars: 10
- Watchers: 1
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RocksDB D-Lang
A straightforward binding to RocksDB v5.0.1 in D-lang.
## Building
You need a valid rocksdb library in the root of this project so your linker can find it. It is recommended to use a recent version of rocksdb, tested with
- facebook-rocksdb-v5.12.4 (https://github.com/facebook/rocksdb/archive/v5.12.4.tar.gz)
Note: Windows rocksdb will work and recommendation is to use vcpkg to build rocks first, and copy your rocksdb-shared.dll into the root of the parent project.
## Testing
> dub test
will launch a benchmark, and should be enough to convine one of the functionality and performance.
## Example
```D
auto opts = new DBOptions;
opts.createIfMissing = true;
opts.errorIfExists = false;
auto db = new Database(opts, "testdb");
// Put a value into the database
db.putString("key", "value");
// Get a value out
assert(db.getString("key") == "value");
ubyte[] key = ['\x00', '\x00'];
// Delete a value
db.remove(key);
// Add values in bulk
auto batch = new WriteBatch;
for (int i = 0; i < 1000; i++) {
batch.putString(i.to!string, i.to!string);
}
db.write(batch);
// Iterate over the DB
auto iter = db.iter();
foreach (key, value; iter) {
db.remove(key);
}
destroy(iter);
// Close the database
db.close();
```