Encrypted TTL-based key-value store with sandboxed hooks and optional persistence backends (SQLite/File/Redis).
Project description
LiveDict (Release v1.0.4)
Encrypted, TTL-based, Persistent Python Dictionary with Hook Callbacks
LiveDict is a secure, extensible, and ephemeral key-value store designed for applications that need in-memory caching with optional persistence and encryption.
License
MIT License. © 2025 LiveDict. All rights reserved.
Highlights
- AES-GCM encryption (via
cryptography) with a deterministic fallback for test environments. - TTL expiry driven by a heap-based monitor thread for efficient scheduling.
- Optional persistence backends:
- SQLite (file-backed DB)
- File-backed object store (per-bucket files)
- Redis (thin wrapper; requires
redispackage)
- Hook callbacks (
on_access,on_expire) executed safely (sandboxing recommended). - Pydantic-backed configuration models for clarity and validation.
- Bucket policies and limits to control memory usage and namespaces.
Installation
Minimum supported Python: 3.8+
Install with:
pip install livedict
Quick Start
from livedict import LiveDict, LiveDictConfig, SQLiteBackend, CipherAdapter
# Create a sqlite backend and pass to LiveDict for persistence
db = SQLiteBackend(dsn="sqlite:///livedict.db")
cfg = LiveDictConfig()
store = LiveDict(config=cfg, cipher=CipherAdapter(), backends={"sqlite": db})
store.set("username", "alice", ttl=60)
print(store.get("username")) # -> 'alice'
store.stop() # stop the monitor thread cleanly
Features & Notes
Encryption
- Uses AES-GCM when
cryptographyis available. - Fallback deterministic XOR + base64 if cryptography absent (useful for tests).
- Keep the same CipherAdapter (or same keys) across restarts to decrypt persisted blobs.
Persistence Backends
- SQLiteBackend uses short-lived connections and has an any-bucket fallback lookup.
- FileBackend stores entries as per-bucket small files with JSON metadata.
- RedisBackend is a thin wrapper —
redis-pyrequired for full functionality.
Configuration & Limits
- Use pydantic
LiveDictConfigto tune defaults, monitor behavior, and backend settings. - Memory limits and heap rebuild thresholds help avoid large memory usage.
Documentation
See
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file livedict-1.0.4.tar.gz.
File metadata
- Download URL: livedict-1.0.4.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5220e265a0486ce42aa43bd9287c1930243bcf456d4b17e7b7f12d05e82163e0
|
|
| MD5 |
71970c47a8405226af898cfc6053e86b
|
|
| BLAKE2b-256 |
b87cf0754e95489afe081670a523dfde3ce0501189f9122872fdeeb3b4162d1a
|
File details
Details for the file livedict-1.0.4-py3-none-any.whl.
File metadata
- Download URL: livedict-1.0.4-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
155be07c7d7a85715067c40a3e44e32579027b7fc05695843bd0207c744c4b50
|
|
| MD5 |
940dd3cae56f31ebfc8a9c284c3c4b09
|
|
| BLAKE2b-256 |
975c5cc8c4a7c42e9b9f709e5197892c1643687da54c1f2e1069cc9d1a6fc403
|