A boilerplate utility package
Project description
๐ True Storage
A comprehensive Python library for advanced storage management, environment configuration, and session handling.
โจ Features
๐ Advanced Environment Management
- ๐ Multiple environment sources (env files, JSON, config files)
- ๐ Environment validation and type checking
- ๐ Mode-specific variables (dev, test, stage, prod)
- โก Variable interpolation
- ๐ธ Environment snapshots and rollback
- ๐ Optional Pydantic integration
๐ Session Management
- ๐ Thread-safe in-memory session store
- โฐ Automatic expiration and cleanup
- ๐ LRU eviction strategy
- โ๏ธ Configurable size and timeout
๐พ Storage Solutions
- ๐ฅ Hot storage for frequently accessed data
- โ๏ธ Cold storage for archival data
- ๐ Mixed storage strategy
- ๐ ๏ธ Base storage interface for custom implementations
๐๏ธ Database Integration
- ๐ Thread-safe database implementations
- ๐ Filesystem storage with atomic operations
- ๐ฆ Redis support with connection pooling
- ๐ฒ SQLite with BLOB storage optimization
- ๐ Pickle-based serialization
- ๐ท๏ธ Customizable key prefixing
- โ ๏ธ Error handling and connection management
๐ Installation
# Basic installation
pip install true-storage
# With Pydantic support
pip install true-storage[pydantic]
๐ Quick Start
๐ Environment Management
from true_storage.env import Environment, MODES
# Initialize environment
env = Environment(env_data=".env")
# Set mode-specific variables
env.set('API_KEY', 'secret-key', modes=[MODES.PROD])
env.set('DEBUG', 'true', modes=[MODES.DEV])
# Access variables with mode context
with env.with_mode(MODES.PROD):
api_key = env.get('API_KEY') # Only accessible in PROD mode
๐ Session Management
from true_storage.session import SessionStore, SessionStoreConfig
# Configure session store
config = SessionStoreConfig(
max_size=1000,
expiration_time=3600, # 1 hour
cleanup_interval=60 # 1 minute
)
# Initialize session store
store = SessionStore(config)
# Use session store
store.set('user_id', 'user123')
user_id = store.get('user_id')
๐พ Storage Management
from true_storage.storage.hot import HotStorage
from true_storage.storage.cold import ColdStorage
from true_storage.storage.mixed import MixedStorage
# Initialize storage
hot_storage = HotStorage()
cold_storage = ColdStorage()
mixed_storage = MixedStorage()
# Store and retrieve data
mixed_storage.store('key', 'value')
value = mixed_storage.retrieve('key')
๐๏ธ Database Integration
# File System Storage
from true_storage.database import FileSystemStorage
fs_storage = FileSystemStorage(base_dir="/path/to/storage")
fs_storage.store("key", {"data": "value"})
# Redis Storage
from true_storage.database import RedisStorage
redis_storage = RedisStorage(host="localhost", port=6379, prefix="app:")
redis_storage.store("key", ["list", "of", "items"])
# SQLite Storage
from true_storage.database import SQLiteStorage
sqlite_storage = SQLiteStorage(db_path="app.db")
sqlite_storage.store("key", {"complex": "data"})
๐ Documentation
For detailed documentation, visit true-storage.readthedocs.io.
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 true_storage-0.1.0.tar.gz.
File metadata
- Download URL: true_storage-0.1.0.tar.gz
- Upload date:
- Size: 46.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28ea951422bddfb1587df6f89398e50e3fcfaa08c378878786820872673720ba
|
|
| MD5 |
0764ac8236148ab4861755e296d2e951
|
|
| BLAKE2b-256 |
17b47f6e78fbd0041dd9e22f039867060643b41ec894e350ce5f65ba1f93785e
|
File details
Details for the file true_storage-0.1.0-py3-none-any.whl.
File metadata
- Download URL: true_storage-0.1.0-py3-none-any.whl
- Upload date:
- Size: 61.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8cac946adcbfdf47e9d57156ee0090738dfc9a92cf664afb03f3e5a6bc35e3e
|
|
| MD5 |
5a3cc8cf25b55c66a3c68b78b5914bf4
|
|
| BLAKE2b-256 |
fd8ba5c7f0f95e6577af819c2de8386dd5ceb39da36add5da3e6ed0dca723d3a
|