No project description provided
Project description
Redis Mutator
Inject another Redis connection to your Redis connection!
Installation
pip install redis-mutator
Uses
- Separate read-only functions to another Redis connection.
- Log functions as you use them.
How to Use
from redis_mutator import mutate, READ_METHOD_NAMES
from redis import Redis
redis = Redis(...)
read_only_redis = Redis(...)
mutate(redis, READ_METHOD_NAMES).use(read_only_redis)
redis.sadd("hello", "world!") # Uses `redis`.
redis.smembers("hello") # Uses `read_only_redis`.
Specify Method Names
from redis_mutator import mutate
from redis import Redis
redis = Redis(...)
my_other_redis = Redis(...)
mutate(redis, "sadd", "spop").use(my_other_redis)
redis.sadd("hello", "world!") # Uses `my_other_redis`.
redis.spop("hello", 1) # Uses `my_other_redis`.
redis.hset("hello", "world", "hi") # Uses `redis`.
redis.hget("hello", "world") # Uses `redis`.
Prefix & Postfix Hooks
from redis_mutator import mutate
from redis import Redis
redis = Redis(...)
my_other_redis = Redis(...)
def prefix(*args, **kwargs):
print('Prefix called.')
def postfix(value):
print('Postfix called.')
mutate(redis, "sadd", "spop").prefix(prefix)
mutate(redis, "sadd", "spop").postfix(postfix)
redis.sadd("hello", "world!")
# Prefix called.
# `redis.sadd(...)`
# Postfix called.
Override Methods
from redis_mutator import mutate
from redis import Redis
redis = Redis(...)
my_other_redis = Redis(...)
def prefix(*args, **kwargs):
print('Hi-jacked!')
return False # Return `False` to stop the process.
mutate(redis, "sadd", "spop").prefix(prefix)
redis.sadd("hello", "world!") # Hi-jacked!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redis_mutator-0.2.4.tar.gz
(3.1 kB
view details)
Built Distribution
File details
Details for the file redis_mutator-0.2.4.tar.gz
.
File metadata
- Download URL: redis_mutator-0.2.4.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.8.10 Linux/5.15.0-102-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bd9fa8037a94c90982462fa084c7a595af5b15682a414b9966c7b497cbfdc7b |
|
MD5 | 4e9793bd6e306d5132451c7c74440dde |
|
BLAKE2b-256 | 357e408bcbf66250a386b96fae76e38492f183f73cb0c36ac40183b07820ded4 |
File details
Details for the file redis_mutator-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: redis_mutator-0.2.4-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.8.10 Linux/5.15.0-102-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4c00c6be7aab1f49e07a4063fa832166cfbee76fe95e4a9d015e622e0e7ae98 |
|
MD5 | 25bdffedea1acc19d34e5ca1a1d1f856 |
|
BLAKE2b-256 | e8f871dac80249161cc177d8ae881cf24234241dad58916db4a0eeafaf8b0bcf |