
Zep Key-Value Store
Zep-kvs is an elementary zero config cross platform key-value persistence library. Arbitrary application data can be associated with named keys that can later be retrieved from an operating system appropriate location.
Features
- Zero Configuration: No setup required - just start storing data
- Cross Platform: Works on Linux, macOS, and Windows
- Type Safe: Generic API with automatic serialization/deserialization
- Multiple Scopes: Store data at user or machine level
- Ephemeral Storage: In-memory storage for testing
- Platform Native: Uses appropriate storage locations for each OS
What Zep-KVS Is NOT
To set proper expectations, it's important to understand what zep-kvs is not designed for:
-
Not a Database: Zep-kvs is not a replacement for PostgreSQL, SQLite, or other databases. It doesn't support queries, transactions, or relational data.
-
Not Distributed: This is not a distributed key-value store like Redis, etcd, or Consul. It only stores data locally on a single machine.
-
Not High-Performance: Zep-kvs prioritizes simplicity over performance. It's not optimized for high-throughput or low-latency operations.
-
Not a Cache: While it can store temporary data, it's not designed as a caching layer with features like TTL, LRU eviction, or cache invalidation.
-
Not Network-Accessible: Data is only accessible to the local application. There's no network interface or API for remote access.
-
Not for Large Data: It's designed for small application settings and configuration data, not for storing large files or datasets.
-
Not ACID Compliant: While individual operations are atomic, there's no support for multi-key transactions or complex consistency guarantees.
Zep-kvs is perfect for storing application preferences, user settings, small configuration data, and other simple key-value pairs that need to persist between application runs.
Storage Locations
Zep-kvs automatically selects the appropriate storage location based on your operating system:
Linux
- User scope:
$XDG_DATA_HOMEor~/.local/share - Machine scope:
/var/lib
MacOS
- User scope:
~/Library/Application Support - Machine scope:
/Library/Application Support
Windows
- User scope:
HKEY_CURRENT_USER\Software - Machine scope:
HKEY_LOCAL_MACHINE\Software
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
Basic Example
use *;
Storage Scopes
Zep-kvs supports three different storage scopes:
User Scope
Store data specific to the current user:
use *;
let mut store = new?;
store.store?;
Machine Scope
Store data system-wide (requires appropriate permissions):
use *;
let mut store = new?;
store.store?;
Ephemeral Scope
Store data in memory only (useful for testing):
use *;
let mut store = new?;
store.store?;
// Data is lost when the store is dropped
Data Types
Zep-kvs can store and retrieve various data types:
use *;
let mut store = new?;
// Strings
store.store?;
let name: String = store.retrieve?.unwrap;
// Numbers
store.store?;
let age: u32 = store.retrieve?.unwrap;
// Binary data
let data = vec!;
store.store?;
let retrieved: = store.retrieve?.unwrap;
// Check if a key exists
if let Some = store.? else
Error Handling
Zep-kvs provides detailed error information:
use *;
match new
Platform-Specific Notes
Linux
- User scope requires a home directory
- Machine scope requires write permissions to
/var/lib - Respects XDG Base Directory Specification
MacOS
- Follows macOS conventions for application data storage
- Creates directories as needed in
Application Support - Requires appropriate permissions for machine scope
Windows
- Uses Windows Registry for persistent storage
- User scope stores in
HKEY_CURRENT_USER - Machine scope requires administrator privileges
Requirements
- Rust 1.75+ (uses
edition = "2024")
License
Licensed under the BSD-2-Clause license. See LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.