Registry / database / py-redis

py-redis

JSON →
library1.1.1pypypi✓ verified 85d ago

py-redis is a convenience wrapper for the official `redis-py` package, simplifying Redis client instantiation. It allows configuring the client via environment variables (REDIS_HOST, REDIS_PORT, REDIS_DB, REDIS_PASSWORD) and provides a single function to get a pre-configured `redis.Redis` instance. The current version is 1.1.1, and its release cadence is infrequent as it primarily provides a thin stable wrapper.

pip install py-redis
INSTALL
IMPORT
SIG · PY-REDIS
P
py-redis
databasepythonv1.1.1
Install
1.9s avg
Import
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.6MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.9s · import 0.000s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RedisConnection
from pyredis import RedisConnection
from pyredis import get_redis_client
wrapper
from pyredis import wrapper

This quickstart demonstrates how to get a Redis client using `get_redis_client`, leveraging environment variables for configuration. It then performs a basic `set` and `get` operation, ensuring `decode_responses=True` for string handling.

import os from pyredis import get_redis_client # Configure Redis connection via environment variables for robustness # Example: REDIS_HOST=localhost REDIS_PORT=6379 REDIS_DB=0 REDIS_PASSWORD="" # Fallback to defaults if env vars are not set redis_host = os.environ.get('REDIS_HOST', 'localhost') redis_port = int(os.environ.get('REDIS_PORT', '6379')) redis_db = int(os.environ.get('REDIS_DB', '0')) redis_password = os.environ.get('REDIS_PASSWORD') or None try: # Get a configured Redis client instance # decode_responses=True is highly recommended for working with strings redis_client = get_redis_client( host=redis_host, port=redis_port, db=redis_db, password=redis_password, decode_responses=True ) # Test the connection redis_client.ping() print("Successfully connected to Redis!") # Perform a simple operation redis_client.set('mykey', 'Hello, py-redis!') value = redis_client.get('mykey') print(f"Retrieved from Redis: {value}") redis_client.delete('mykey') # Clean up except Exception as e: print(f"Could not connect to Redis or an error occurred: {e}") print("Please ensure Redis server is running and connection details are correct.")
Debug
Known issues
gotchaParameters passed directly to `get_redis_client()` will override any corresponding environment variables (e.g., `REDIS_HOST`, `REDIS_PORT`). Ensure your explicit arguments align with or intentionally override your environment setup.
fix
Explicitly check both environment variables and `get_redis_client` call arguments to understand the final configuration applied.
affects: All versions
gotchaBy default, `redis-py` (and thus `py-redis` if `decode_responses` is not set) returns byte strings. If you omit `decode_responses=True`, you'll receive bytes, which can lead to `TypeError` when expecting strings (e.g., in JSON serialization).
fix
Always explicitly set `decode_responses=True` in `get_redis_client()` if you expect Python strings, or manually decode the byte strings using `.decode('utf-8')` after retrieval.
affects: All versions
gotchaAs `py-redis` is a thin wrapper around `redis-py`, breaking changes or deprecations in the underlying `redis-py` library (which `py-redis` depends on) can indirectly affect your application, especially if `redis-py` itself is updated.
fix
Refer to `redis-py`'s changelog for major version updates. Ensure your `redis-py` dependency (either explicit or through `py-redis`'s requirements) is stable and compatible with your `py-redis` version.
affects: Any version where `redis-py` has major updates
Upgrade
Version history
1.1.1latest on PyPI · released Dec 13, 2021
Audit
Dependencies
redisrequiredRequired as `py-redis` wraps the official `redis-py` client library.
Agent activity
17 hits · last 30 days
node
14
Amazon
1
Resources
py-redis — pip install py-redis · libregistry