Extract DB
A thread-safe, in-memory hash store supporting concurrent fetches and writes.
This is not a traditional kv-store, in the sense that it doesn't use any form of keys. Specific "item" removal is not supported in favor of a fetching type system and can be thought of as a read-only dequeue database.
Table of contents
- Guarantees
- Trade-offs
- Use scenarios
- Installation
- Examples
- Basics
- Multithreaded
- Disk
- Testing
- Contributing
- License
Guarantees.
- All items will eventually be fetched (no duplication), but ordering is non-deterministic (Not FIFO or FILO)
- Items are never removed once inserted (append-only / reference-fetching)
- All functions are thread safe
Trade-offs.
- No item removal
- Non-deterministic fetch order
- Write throughput is prioritized over reading performance
Use scenarios:
- Concurrent queue with unique items only (
HashSet+VecDeque)-like - Fast concurrent insertions are needed over concurrent reads
- Fast reading on a single-thread with multiple concurrent writers
- Persistent in-memory hash-store
This was originally built for a web-scraper which needs to write lots of links with fewer reads.
Installation
# Cargo.toml
[]
= "0.1.0"
Examples
Push, fetch, & count
use ExtractDb;
Multithreaded insert & fetch
use Arc;
use ExtractDb;
use thread;
Disk loading and saving
use PathBuf;
use ExtractDb;
Auto saving
use Arc;
use PathBuf;
use ;
use ;
Testing + More examples
This project includes some basic tests to maintain functionality please use them.
cargo test
See internal doc-comments for more indepth information about each test:
pushpush_multiplepush_collidedpush_multi_threadpush_structurecount_empty_storecount_loaded_storefetch_datafetch_data_multiplefetch_data_emptyduplicate_fetchsave_state_to_diskload_state_from_diskload_corrupted_state_from_diskload_shard_mismatch_from_diskload_mismatch_type_from_disk
Contributing
Pull request and issue contributions are very welcome. Please feel free to suggest changes in PRs/Issues :)
License
This project is licensed under either MIT or Apache-2.0, you choose.