Dive is a key-value caching system built in Rust, designed to offer robust security and stability with the performance benefits of Rust. It is a simple and easy-to-use caching solution that supports various advanced features for managing key-value stores efficiently.
- In-Memory Key-Value Store: Efficiently store and retrieve key-value pairs.
- Frequency-Based Eviction: Implements LFU (Least Frequently Used) eviction policy to manage cache size.
- File Persistence: Save and load the store from CSV files for persistent storage.
- Concurrency Support: Utilize async operations for high concurrency and performance.
- Basic HTTP API: Interact with the cache through a RESTful API built with Axum.
- CLI Functionality: Add command-line interface tools for managing the cache.
- Additional HTTP Handlers: Implement more HTTP endpoints for extended functionality.
- Max Store Size: Introduce limits on the size of each store.
- Periodic Snapshots & Write-Ahead Logging: Ensure data integrity and recovery.
- Automatic LFU & LRU Eviction: Improve eviction strategies for better cache management.
To run Dive locally, follow these steps:
-
Clone the Repository:
git clone https://github.com/Cedar-81/dive cd dive
-
Build and Run:
Make sure you have Rust installed. If not, you can install it from rust-lang.org.
cargo build cargo run
This will start the server on
http://127.0.0.1:3000
.
- Endpoint:
/create-store
- Method:
POST
- Description: Creates a new key-value store instance.
- Response: Returns the ID of the newly created store.
-
Endpoint:
/insert/:instance_id
-
Method:
POST
-
Description: Inserts key-value pairs into the specified store instance.
-
Request Body:
{ "data": [ ["key1", "value1"], ["key2", "value2"] ] }
-
Response: Status of the insertion operation.
- Endpoint:
/get/:id
- Method:
GET
- Description: Retrieves the value for a specified key from the store instance.
- Response: Returns the stored value or an error message.
Here’s an example of how to use the API with curl
:
-
Create a Store:
curl -X POST <http://localhost:3000/create-store>
-
Insert Data:
curl -X POST <http://localhost:3000/insert/><instance_id> -H "Content-Type: application/json" -d '{"data":[["key1","value1"]]}'
-
Retrieve Data:
curl -X GET <http://localhost:3000/get/><instance_id>
We welcome contributions to Dive! If you have suggestions or improvements, please open an issue or submit a pull request.
- Fork the Repository: Make changes in your fork and test them.
- Submit a Pull Request: Describe your changes and why they are needed.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or feedback, please reach out to [email protected].