🚀 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.
Metadata
Release files for true-storage 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| true_storage-0.1.0.tar.gz | 46.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| true_storage-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 107.7 kB
Release files / true_storage-0.1.0.tar.gz
| Download URL | true_storage-0.1.0.tar.gz |
|---|---|
| Size | 46.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28ea951422bddfb1587df6f89398e50e3fcfaa08c378878786820872673720ba
|
|
BLAKE2b-256 checksum How to use checksums |
17b47f6e78fbd0041dd9e22f039867060643b41ec894e350ce5f65ba1f93785e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.6
|
Release files / true_storage-0.1.0-py3-none-any.whl
| Download URL | true_storage-0.1.0-py3-none-any.whl |
|---|---|
| Size | 61.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8cac946adcbfdf47e9d57156ee0090738dfc9a92cf664afb03f3e5a6bc35e3e
|
|
BLAKE2b-256 checksum How to use checksums |
fd8ba5c7f0f95e6577af819c2de8386dd5ceb39da36add5da3e6ed0dca723d3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.6
|