3 unstable releases
0.4.1 | Sep 5, 2023 |
---|---|
0.4.0 | Sep 5, 2023 |
0.3.0 | Aug 14, 2023 |
#184 in Database implementations
42 downloads per month
185KB
1K
SLoC
π Readatabase (readb)
π¨ Update Alert: BREAKING CHANGES in 0.4.0
- π Refactored database code structure. You must now use
use readb::Database;
. - β
The constructor no longer needs
unwrap()
. An.unwrap()
method remains for backward compatibility.- π Instead, we've introduced the
create_path
attribute inDatabaseSettings
. This could be a breaking change if you arenβt using theDefault
.
- π Instead, we've introduced the
π "Don't reinvent the wheel." Despite this wisdom, here we are with readb: a fresh, streamlined embedded key-value database crafted in pure Rust.
Balancing simplicity akin to sled, readb boasts outstanding read performance. Primarily focused on reads, it also caters to writes and deletes. It remains lightweight with minimal dependencies and under 200KB size.
π Features
- Custom Cache: Choose from an array of caching strategies (some still under development).
- Lock-Free Reads: Optimized for concurrent access.
- Remote Cloning: Sync your data with ease.
- Transactions: Secure and efficient data modifications.
π Speed Secrets of readb
readb thrives on being read-centric. Assuming data remains largely static, we strike a balance between memory efficiency and speed by leveraging disk and memory effectively.
Data management includes:
- link: Associate without duplicating.
- put: Append data linearly for quick access.
readb's linear approach stands out from the norm, ensuring swift operations.
π― Ideal Users?
If you predominantly deal with read requests and yearn for a speedy, efficient local solution, readb awaits. While it excels in write speeds, it does so with minor compromises on compression.
π Benchmarks
Write Benchmark:
Operations | readb max time |
sled max time |
---|---|---|
1,000 | 147.02 Β΅s | 332.65 Β΅s |
1,000,000 | 238.48 ms | 485.63 ms |
Read Benchmark:
Benchmark type | time readb | time sled | time redb |
---|---|---|---|
Retrieve 1000 items | 50.30 | 79.25 | 97.95 |
Retrieve 1000 items (10 percent) | 49.05 | 17.84 | 22.39 |
Retrieve 1000 items (20 percent with repetitions) | 49.16 | 33.92 | 43.17 |
Retrieve 10000 items | 67.56 | 1,256.75 | 1,225.68 |
Retrieve 10000 items (10 percent) | 55.29 | 311.57 | 357.98 |
Retrieve 10000 items (20 percent with repetitions) | 61.13 | 541.79 | 692.16 |
Retrieve 100000 items | 209.59 | 36,977 | 52,558 |
Retrieve 100000 items (10 percent) | 86.25 | 3,465.1 | 5,090.9 |
Retrieve 100000 items (20 percent with repetitions) | 124.29 | 6,831.8 | 10,151 |
Visuals:
π Getting Started
1. Database Setup
The Database
struct manages indexing, caching, and data loading and requires two generics:
C
: Cache mechanism (implement theCache
trait).L
: Data loader (implement theLoader
trait).
2. Operations:
From fetching keys to maintaining data consistency, we've got you covered.
3. Advanced Features:
From data writes to efficient garbage management, elevate your database game.
π£ Roadmap to 1.0
With a stabilized API, our focus shifts to refining caching and enhancing documentation. As we inch towards our 1.0 release, backward compatibility remains paramount.
π License
Licensed under the Apache License, Version 2.0. Dive into the NOTICE file for more details.
Dependencies
~0.5β13MB
~197K SLoC