#key-value #key-value-store #type-safe #delete #set-key #storage #pair

app kvstore

A simple, typesafe key-value store, that allows users to set, get, and delete key-value pairs, with each key stored in a separate file on disk

3 unstable releases

0.2.1 Feb 21, 2024
0.2.0 Dec 31, 2023
0.1.0 Dec 26, 2023

#180 in Filesystem

Download history 4/week @ 2023-12-26 1/week @ 2024-02-13 136/week @ 2024-02-20 40/week @ 2024-02-27 3/week @ 2024-03-12 10/week @ 2024-03-26 38/week @ 2024-04-02

51 downloads per month

Custom license

30KB
660 lines

Rust-Based Key-Value Store Tool

Overview

This tool is a simple yet powerful key-value store, implemented in Rust. It allows users to set, get, and delete key-value pairs, with each key stored in a separate file on disk. Inspired by Android's Shared Preferences, it supports different data types like String, Integer, and Float.

Features

  • Set, Get, Delete Operations: Perform basic key-value operations.
  • Type Checking: Handles different data types, including strings, integers, and floats.
  • File-Based Storage: Each key-value pair is stored in a separate file for persistence.
  • Command-Line Interface: Easy to use with simple command-line arguments.

Installation

From crates.io

cargo install kvstore 

c

From Source

Ensure you have Rust and Cargo installed on your system. Follow these steps to install:

  1. Clone the repository:
    git clone [repository-url]
    
  2. Navigate to the project directory:
    cd my_kv_store
    
  3. Build the project using Cargo:
    cargo build --release
    

Usage

After building the project, you can run the tool using the Cargo run command followed by the operation you want to perform.

Set a generic Key-Value Pair

cargo run -- set <key> <value> [--type <type>]
  • <key>: The key for the value.
  • <value>: The value to store.
  • <type>: The type of the value (String, Integer, Float). Default is String.

Using set will infer a type for the value. If you want to specify the value, you can use one of the following instead:

  • setString
  • setInteger
  • setFloat

Get a Value

cargo run -- get <key>
  • <key>: The key of the value to retrieve.

Using get will return the type as well as the value - something like String:hello. If you want to specify the value, you can use one of the following instead:

  • getString
  • getInteger
  • getFloat

Delete a Key-Value Pair

cargo run -- delete <key>
  • <key>: The key of the value to delete.

Contributing

Contributions to this project are welcome! Feel free to fork the repository and submit pull requests.

License

This project is licensed under The MIT License - see the LICENSE file for details.

Dependencies

~1–10MB
~68K SLoC