true-storage


Nametrue-storage JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/alaamer12/true-storage
SummaryA boilerplate utility package
upload_time2024-12-07 21:11:46
maintainerNone
docs_urlNone
authoralaamer12
requires_python<4.0,>=3.11
licenseMIT
keywords
VCS
bugtrack_url
requirements redis python-dotenv pytest colorama setuptools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🚀 True Storage

[![PyPI version](https://badge.fury.io/py/true-storage.svg)](https://badge.fury.io/py/true-storage)
[![Documentation Status](https://readthedocs.org/projects/true-storage/badge/?version=latest)](https://true-storage.readthedocs.io/en/latest/?badge=latest)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/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

```bash
# Basic installation
pip install true-storage

# With Pydantic support
pip install true-storage[pydantic]
```

## 📚 Quick Start

### 🌍 Environment Management

```python
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

```python
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

```python
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

```python
# 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](https://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](LICENSE.txt) file for details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/alaamer12/true-storage",
    "name": "true-storage",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "alaamer12",
    "author_email": "ahmedmuhmmed239@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/17/b4/7f6e78fbd0041dd9e22f039867060643b41ec894e350ce5f65ba1f93785e/true_storage-0.1.0.tar.gz",
    "platform": null,
    "description": "# \ud83d\ude80 True Storage\n\n[![PyPI version](https://badge.fury.io/py/true-storage.svg)](https://badge.fury.io/py/true-storage)\n[![Documentation Status](https://readthedocs.org/projects/true-storage/badge/?version=latest)](https://true-storage.readthedocs.io/en/latest/?badge=latest)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA comprehensive Python library for advanced storage management, environment configuration, and session handling.\n\n## \u2728 Features\n\n### \ud83c\udf0d Advanced Environment Management\n- \ud83d\udcc1 Multiple environment sources (env files, JSON, config files)\n- \ud83d\udd10 Environment validation and type checking\n- \ud83d\udd04 Mode-specific variables (dev, test, stage, prod)\n- \u26a1 Variable interpolation\n- \ud83d\udcf8 Environment snapshots and rollback\n- \ud83d\udd0c Optional Pydantic integration\n\n### \ud83d\udd04 Session Management\n- \ud83d\udd12 Thread-safe in-memory session store\n- \u23f0 Automatic expiration and cleanup\n- \ud83d\udcca LRU eviction strategy\n- \u2699\ufe0f Configurable size and timeout\n\n### \ud83d\udcbe Storage Solutions\n- \ud83d\udd25 Hot storage for frequently accessed data\n- \u2744\ufe0f Cold storage for archival data\n- \ud83d\udd04 Mixed storage strategy\n- \ud83d\udee0\ufe0f Base storage interface for custom implementations\n\n### \ud83d\uddc4\ufe0f Database Integration\n- \ud83d\udd12 Thread-safe database implementations\n- \ud83d\udcc1 Filesystem storage with atomic operations\n- \ud83d\udce6 Redis support with connection pooling\n- \ud83c\udfb2 SQLite with BLOB storage optimization\n- \ud83d\udd04 Pickle-based serialization\n- \ud83c\udff7\ufe0f Customizable key prefixing\n- \u26a0\ufe0f Error handling and connection management\n\n## \ud83d\ude80 Installation\n\n```bash\n# Basic installation\npip install true-storage\n\n# With Pydantic support\npip install true-storage[pydantic]\n```\n\n## \ud83d\udcda Quick Start\n\n### \ud83c\udf0d Environment Management\n\n```python\nfrom true_storage.env import Environment, MODES\n\n# Initialize environment\nenv = Environment(env_data=\".env\")\n\n# Set mode-specific variables\nenv.set('API_KEY', 'secret-key', modes=[MODES.PROD])\nenv.set('DEBUG', 'true', modes=[MODES.DEV])\n\n# Access variables with mode context\nwith env.with_mode(MODES.PROD):\n    api_key = env.get('API_KEY')  # Only accessible in PROD mode\n```\n\n### \ud83d\udd04 Session Management\n\n```python\nfrom true_storage.session import SessionStore, SessionStoreConfig\n\n# Configure session store\nconfig = SessionStoreConfig(\n    max_size=1000,\n    expiration_time=3600,  # 1 hour\n    cleanup_interval=60    # 1 minute\n)\n\n# Initialize session store\nstore = SessionStore(config)\n\n# Use session store\nstore.set('user_id', 'user123')\nuser_id = store.get('user_id')\n```\n\n### \ud83d\udcbe Storage Management\n\n```python\nfrom true_storage.storage.hot import HotStorage\nfrom true_storage.storage.cold import ColdStorage\nfrom true_storage.storage.mixed import MixedStorage\n\n# Initialize storage\nhot_storage = HotStorage()\ncold_storage = ColdStorage()\nmixed_storage = MixedStorage()\n\n# Store and retrieve data\nmixed_storage.store('key', 'value')\nvalue = mixed_storage.retrieve('key')\n```\n\n### \ud83d\uddc4\ufe0f Database Integration\n\n```python\n# File System Storage\nfrom true_storage.database import FileSystemStorage\nfs_storage = FileSystemStorage(base_dir=\"/path/to/storage\")\nfs_storage.store(\"key\", {\"data\": \"value\"})\n\n# Redis Storage\nfrom true_storage.database import RedisStorage\nredis_storage = RedisStorage(host=\"localhost\", port=6379, prefix=\"app:\")\nredis_storage.store(\"key\", [\"list\", \"of\", \"items\"])\n\n# SQLite Storage\nfrom true_storage.database import SQLiteStorage\nsqlite_storage = SQLiteStorage(db_path=\"app.db\")\nsqlite_storage.store(\"key\", {\"complex\": \"data\"})\n```\n\n## \ud83d\udcd6 Documentation\n\nFor detailed documentation, visit [true-storage.readthedocs.io](https://true-storage.readthedocs.io/).\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE.txt) file for details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A boilerplate utility package",
    "version": "0.1.0",
    "project_urls": {
        "Documentation": "https://true-storage.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/alaamer12/true-storage",
        "Repository": "https://github.com/alaamer12/true-storage"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fd8ba5c7f0f95e6577af819c2de8386dd5ceb39da36add5da3e6ed0dca723d3a",
                "md5": "5a3cc8cf25b55c66a3c68b78b5914bf4",
                "sha256": "d8cac946adcbfdf47e9d57156ee0090738dfc9a92cf664afb03f3e5a6bc35e3e"
            },
            "downloads": -1,
            "filename": "true_storage-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5a3cc8cf25b55c66a3c68b78b5914bf4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 61702,
            "upload_time": "2024-12-07T21:11:44",
            "upload_time_iso_8601": "2024-12-07T21:11:44.225024Z",
            "url": "https://files.pythonhosted.org/packages/fd/8b/a5c7f0f95e6577af819c2de8386dd5ceb39da36add5da3e6ed0dca723d3a/true_storage-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "17b47f6e78fbd0041dd9e22f039867060643b41ec894e350ce5f65ba1f93785e",
                "md5": "0764ac8236148ab4861755e296d2e951",
                "sha256": "28ea951422bddfb1587df6f89398e50e3fcfaa08c378878786820872673720ba"
            },
            "downloads": -1,
            "filename": "true_storage-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0764ac8236148ab4861755e296d2e951",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 46043,
            "upload_time": "2024-12-07T21:11:46",
            "upload_time_iso_8601": "2024-12-07T21:11:46.222552Z",
            "url": "https://files.pythonhosted.org/packages/17/b4/7f6e78fbd0041dd9e22f039867060643b41ec894e350ce5f65ba1f93785e/true_storage-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-07 21:11:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "alaamer12",
    "github_project": "true-storage",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "redis",
            "specs": [
                [
                    ">=",
                    "4.5.0"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "~=",
                    "8.3.4"
                ]
            ]
        },
        {
            "name": "colorama",
            "specs": [
                [
                    "~=",
                    "0.4.6"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    "~=",
                    "75.3.0"
                ]
            ]
        }
    ],
    "lcname": "true-storage"
}
        
Elapsed time: 1.01413s