https://github.com/capocasa/limdb
Fast, in-process key-value store with a table-like interface persisted to disk using lmdb.
https://github.com/capocasa/limdb
Last synced: 4 months ago
JSON representation
Fast, in-process key-value store with a table-like interface persisted to disk using lmdb.
- Host: GitHub
- URL: https://github.com/capocasa/limdb
- Owner: capocasa
- License: mit
- Created: 2022-06-05T23:31:03.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-12T10:30:12.000Z (about 2 years ago)
- Last Synced: 2024-12-31T16:49:38.180Z (6 months ago)
- Language: Nim
- Size: 239 KB
- Stars: 36
- Watchers: 3
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
- awesome-nim - limdb - Very high performance, persistent and safe key-value store based on LMDB with Nim table-like interface. (Data / Database)
README
LimDB
=====Fast, in-process key-value store with a table-like interface persisted to disk using lmdb.
Why?
----Memory-mapped files are one of the fastest ways to store data but are not safe to
access concurrently. Lmdb is a proven and mature to solution to that problem,
offering full compliance to ACID3, a common standard for database reliability, while
keeping most of the speed.Leveraging the excellent nim-lmdb interface, LimDB makes a larg-ish sub-set of lmdb features
available in an interface familiar to Nim users who have experience with a table.While programming with LimDB feels like using a table, it is still very much lmdb.
Some common boilerplate is automated and LimDB is clever about bundling lmdb's moving
parts, but there are no bolted-on bits or obscuring of lmdb's behavior.Installation
------------nimble install https://github.com/capocasa/limdb
Simple Usage
------------Provide LimDB with a local storage directory and then use it like you would use a table. After
inserting the element, it's on disk an can be accessed even after the program is restarted,
or concurrently by different threads or processes.```nim
import limdb
let db = initDatabase("myDirectory")
db["foo"] = "bar" # that's it, foo -> bar is now on disk
echo db["foo"] # prints bar
```
Now if you comment out the write, you can run the program again and read the value off disk```nim
import limdb
let db = initDatabase("myDirectory")
# db["foo"] = "bar"
echo db["foo"] # also prints "bar"
```
That's it. If you just need to quickly save some data, you can stop reading here and start programming.You can go much deeper though- convenient transactions, read/write derived from code, all Nim data types except `ref`, a convenient initialization syntaxes to initialize multiple databases and transactions that span them.
[API Documentation](https://capocasa.github.io/limdb/limdb.html)