Metadata-Version: 2.4
Name: pico-data-redis
Version: 0.1.0
Summary: Redis integration for the Pico ecosystem: shared client, distributed cache backend for pico-caching.
Author-email: David Perez Cabrera <dperezcabrera@gmail.com>
License: MIT License
        
        Copyright (c) 2025 David Pérez Cabrera
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/dperezcabrera/pico-data-redis
Project-URL: Documentation, https://dperezcabrera.github.io/pico-data-redis/
Project-URL: Repository, https://github.com/dperezcabrera/pico-data-redis
Project-URL: Changelog, https://github.com/dperezcabrera/pico-data-redis/blob/main/CHANGELOG.md
Project-URL: Issue Tracker, https://github.com/dperezcabrera/pico-data-redis/issues
Keywords: redis,cache,distributed,ioc,spring boot
Classifier: Development Status :: 4 - Beta
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pico-ioc>=2.2.0
Requires-Dist: redis>=5
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: pytest-cov>=5; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: fakeredis>=2; extra == "dev"
Requires-Dist: pico-caching>=0.1.0; extra == "dev"
Dynamic: license-file

# pico-data-redis

[![PyPI](https://img.shields.io/pypi/v/pico-data-redis.svg)](https://pypi.org/project/pico-data-redis/)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/dperezcabrera/pico-data-redis)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![CI (tox matrix)](https://github.com/dperezcabrera/pico-data-redis/actions/workflows/ci.yml/badge.svg)
[![codecov](https://codecov.io/gh/dperezcabrera/pico-data-redis/branch/main/graph/badge.svg)](https://codecov.io/gh/dperezcabrera/pico-data-redis)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dperezcabrera_pico-data-redis&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=dperezcabrera_pico-data-redis)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=dperezcabrera_pico-data-redis&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=dperezcabrera_pico-data-redis)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=dperezcabrera_pico-data-redis&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=dperezcabrera_pico-data-redis)
[![PyPI Downloads](https://img.shields.io/pypi/dm/pico-data-redis)](https://pypi.org/project/pico-data-redis/)
[![Docs](https://img.shields.io/badge/Docs-pico--data--redis-blue?style=flat&logo=readthedocs&logoColor=white)](https://dperezcabrera.github.io/pico-data-redis/)
[![Interactive Lab](https://img.shields.io/badge/Learn-online-green?style=flat&logo=python&logoColor=white)](https://dperezcabrera.github.io/pico-learn/)

Redis for the [pico ecosystem](https://github.com/dperezcabrera/pico-ioc): a shared injectable client, and a distributed backend that makes `@cacheable` (pico-caching) work across processes. Installing it is opting in.

## Installation

```bash
pip install pico-data-redis
```

## Quick start

```yaml
redis:
  url: redis://cache.internal:6379/0
```

Inject the shared client anywhere:

```python
from redis import Redis
from pico_ioc import component

@component
class Sessions:
    def __init__(self, redis: Redis):
        self._redis = redis
```

With pico-caching installed, `@cacheable` methods automatically use Redis instead of process memory — no code changes, the interceptor prefers any non-in-memory backend:

```python
from pico_caching import cacheable

@component
class Reports:
    @cacheable(ttl_seconds=300)
    def heavy_query(self, day: str) -> dict: ...
```

Notes:

- Cached values are pickled — treat the Redis instance as trusted, private infrastructure.
- The backend fails open: an unreachable Redis degrades to cache misses, never to errors.
- Keys are namespaced under `redis.cache_prefix` (default `pico:cache:`); `clear()` only touches that namespace.
- The client's pool closes on container shutdown.

## Documentation

Full documentation: https://dperezcabrera.github.io/pico-data-redis/

## License

MIT
