https://github.com/hyperdivision/tinybox
Tiny, single file, scalable key value store based on HAMTs
https://github.com/hyperdivision/tinybox
Last synced: 4 months ago
JSON representation
Tiny, single file, scalable key value store based on HAMTs
- Host: GitHub
- URL: https://github.com/hyperdivision/tinybox
- Owner: hyperdivision
- License: mit
- Created: 2019-07-12T07:18:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-17T09:23:28.000Z (over 6 years ago)
- Last Synced: 2024-11-09T10:11:59.376Z (12 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 53
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tinybox
Tiny, single file, scalable key value store based on HAMTs
```
npm install tinybox
```
Uses the [Hypertrie](https://github.com/mafintosh/hypertrie) trie without the replication parts,
and auto compacts.
Still under development but the storage format should be stable. Upcoming features include batching,
deletions and getting all values out of the store.
## Usage
``` js
const TinyBox = require('tinybox')
const db = new TinyBox('./db')
db.put('hello', 'world', function () {
db.get('hello', console.log)
})
```
## API
#### `db = new TinyBox(storage)`
Create a new tiny store. Storage can be any [random-access-storage](https://github.com/random-access-storage) instance.
For conveinience you can pass a filename as storage as well.
#### `db.get(key, callback)`
Looks up a value. Key can be a buffer or string. If the key does not exist null is passed, otherwise
the a Node object looking like this:
```js
{
key: ,
value:
}
```
#### `db.put(key, [value], [callback])`
Insert a key and optional value.
## License
MIT