python-redis-cache
Basic Redis caching for functions
Decision gist · record as of 2026-08-14
Yes, if you have Redis available and need straightforward function-level caching. The decorator pattern is intuitive and the package is stable with no known vulnerabilities. However, maintenance is aging (507 days since last release); consider it for established, low-change codebases rather than projects requiring active upstream support. Verify Python 3.6 compatibility claims if you target that version.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Redis 5+ running and accessible; arguments and return values must be JSON-serializable by default (or use a custom serializer).
- Low friction install with a single runtime dependency on redis.
- Maintenance status is aging—last release was 507 days ago, though the repository remains active and not archived.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute this package freely provided you include the license notice.
last release 2025-03-25 (507 days) · last repo commit 2025-03-25 · 115 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 200,799 downloads/mo, #9,683 on PyPI
Alternatives
Verify before relying
pip install python-redis-cache
from redis import StrictRedis
client = StrictRedis(host="redis", decode_responses=True)
# Create cache instance and decorate function
@cache.cache()
def my_func(arg1, arg2):
return expensive_operation()
my_func(1, 2) # Cached on second call
my_func.invalidate(1, 2) # Clear specific entry
my_func.invalidate_all() # Clear all entries- Whether Python 3.6 compatibility claim ('should work in Python 3.6+, but not tested') reflects actual tested support.
- Current stability and adoption rate given 507 days since last release and aging maintenance status.
- Performance characteristics and overhead of the decorator pattern in production workloads.
What it is and what it does
python-redis-cache wraps Python functions with a decorator that automatically caches their return values in Redis, keyed by function identity and arguments. When a decorated function is called with the same arguments again, the cached result is returned instead of re-executing the function body. It handles serialization of arguments and results (JSON by default), supports time-to-live (TTL) expiration, per-function namespaces, and Redis cluster mode via hash-tag key prefixes.
The package is designed for simple, declarative caching of expensive computations—database queries, API calls, heavy calculations—without modifying function logic. It provides methods to invalidate individual cached entries or clear all cached values for a function, and an optional exception handler to gracefully fall back to the original function if Redis is unavailable. The main constraint is that arguments and return values must be serializable; instance methods require refactoring to static methods or custom serializers to avoid serializing `self`.
Use it for
- Cache expensive database queries or API responses to reduce latency on repeated calls with identical parameters.
- Memoize computationally intensive calculations across multiple function invocations to improve performance.
- Reduce load on external services by caching their responses with a configurable TTL before re-fetching.
- Implement a shared cache layer for multiple Python processes or services using a centralized Redis instance.
- Speed up test suites by caching slow fixture setup or mock data generation across test runs.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you have Redis available and need straightforward function-level caching.
The decorator pattern is intuitive and the package is stable with no known vulnerabilities. However, maintenance is aging (507 days since last release); consider it for established, low-change codebases rather than projects requiring active upstream support. Verify Python 3.6 compatibility claims if you target that version.
Install
python-redis-cache on PyPI
Before you install
Low friction install with a single runtime dependency on redis. Maintenance status is aging—last release was 507 days ago, though the repository remains active and not archived.
Requires Redis 5+ running and accessible; arguments and return values must be JSON-serializable by default (or use a custom serializer).
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute this package freely provided you include the license notice.
Quickstart
pip install python-redis-cache
from redis import StrictRedis
client = StrictRedis(host="redis", decode_responses=True)
# Create cache instance and decorate function
@cache.cache()
def my_func(arg1, arg2):
return expensive_operation()
my_func(1, 2) # Cached on second call
my_func.invalidate(1, 2) # Clear specific entry
my_func.invalidate_all() # Clear all entries
Verify before relying
- Whether Python 3.6 compatibility claim ('should work in Python 3.6+, but not tested') reflects actual tested support.
- Current stability and adoption rate given 507 days since last release and aging maintenance status.
- Performance characteristics and overhead of the decorator pattern in production workloads.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packageredis |
| Maintenance | Aging 507 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 200,799 / month, #9,683 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: python_redis_cache-4.0.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “redis function caching decorator”
- python-redis-cacheDecorator-based caching for Python functions using Redis as the…
- cachierCachier is a decorator that adds persistent, expiring caching to…
- cashewsAsync cache framework with decorator and direct API support for…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also asyncache · cachier · cashews · memoization · aiocache · async-lru · django-redis · django-cacheops · cachetools-async · cachettl