Key-Value Store Library for Automation Controller
This Rust library provides a generic, async-friendly key-value store abstraction supporting multiple backends:
- In-Memory (for fast ephemeral storage)
- Kubernetes ConfigMap/Secret (for distributed configuration)
- SQLite (for persistent local storage)
This is intended for lightweight simple storage. It is by no means high performance or able to provide a high throughput. Especially when using a kubernetes backend, keep in mind that with every set command the configmap or secret will be updated which can cause a high load in the kubernetes api server.
Currently it is mainly designed to be used in a simple smarthome automation controller to provide some simple persistence functionality. It is however designed generically so it can be used wherever deemed useful.
Features
✔ Asynchronous API using tokio
✔ Support for multiple backends (in-memory, Kubernetes, SQLite)
✔ Automatic resource creation for Kubernetes stores
✔ Efficient caching to reduce unnecessary API calls
✔ Clonable storage instances using Arc<T>
✔ Base64 encoding/decoding for Kubernetes Secrets
Installation
Run the following command to add the library to your project:
Usage
1. Create a Store Instance
Manually initialize the store based on your preferred backend.
In-Memory Store
use ;
let store = InMemory;
store.set.await.unwrap;
println!;
Kubernetes ConfigMap Store
use ;
let store = Kubernetes;
store.set.await.unwrap;
println!;
Kubernetes Secret Store (Handles base64 encoding/decoding)
use ;
let store = Kubernetes;
store.set.await.unwrap;
println!;
SQLite Store
use ;
let store = SQLite;
store.set.await.unwrap;
println!;
API Overview
KeyValueStore
Represents a key-value store with different backends.
CRUD Methods
All stores implement the same methods for interacting with key-value data:
License
This project is licensed under the MIT License.