walrus is a Python library providing a set of high-level utilities and abstractions for working with Redis. It offers an object-oriented interface to Redis data structures, including hashes, lists, sets, streams, and also provides features like caching, full-text search, and a graph API. The current version is 0.9.8, with releases occurring periodically, often in response to changes in its underlying `redis-py` dependency.
pip install walrusVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates connecting to a Redis instance and utilizing some of walrus's core features: a Hash for storing structured data, a Set for unique items, and a cached decorator for expensive function calls. Environment variables are used for Redis connection details for robustness.
Upgrade walrus to 0.9.0 or newer: `pip install --upgrade walrus`. Ensure your `redis-py` version is compatible with walrus 0.9.0+.
Upgrade walrus to 0.7.0 or newer: `pip install --upgrade walrus`. If you experience issues, verify your `redis-py` version is 3.0+ (e.g., `pip install 'redis>=3.0'`).
Upgrade walrus to 0.8.2 or newer: `pip install --upgrade walrus`. When interacting with `redis-py` directly for hash operations, prefer `HSET` over `HMSET`.
If your application relies on `None` results *not* being cached, you may need to adjust your caching logic or upgrade to 0.9.1+ and implement custom handling for `None` results if the new behavior is problematic. Check `db.cache.cached` options for `ignore_none` or similar parameters if available (though not explicitly mentioned in docs).
Upgrade walrus to 0.9.0 or newer to ensure compatibility with `redis-py`'s stream APIs: `pip install --upgrade walrus`. Also ensure `redis-py` is updated: `pip install --upgrade redis`.
Always pass your `Database` instance (`db`) to walrus container constructors, e.g., `my_hash = db.Hash('my-key')` instead of `my_hash = Hash('my-key')`.Upgrade your `redis-py` dependency to version 3.0 or newer: `pip install --upgrade 'redis>=3.0'`.