Skip to main content

A boilerplate utility package

Project description

๐Ÿš€ True Storage

PyPI version Documentation Status License: MIT

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

true_storage-0.1.0.tar.gz (46.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

true_storage-0.1.0-py3-none-any.whl (61.7 kB view details)

Uploaded Python 3

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

Hashes for true_storage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 28ea951422bddfb1587df6f89398e50e3fcfaa08c378878786820872673720ba
MD5 0764ac8236148ab4861755e296d2e951
BLAKE2b-256 17b47f6e78fbd0041dd9e22f039867060643b41ec894e350ce5f65ba1f93785e

See more details on using hashes here.

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

Hashes for true_storage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8cac946adcbfdf47e9d57156ee0090738dfc9a92cf664afb03f3e5a6bc35e3e
MD5 5a3cc8cf25b55c66a3c68b78b5914bf4
BLAKE2b-256 fd8ba5c7f0f95e6577af819c2de8386dd5ceb39da36add5da3e6ed0dca723d3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page