Tutorial by Examples

import redis r = redis.StrictRedis(host='localhost', port=6379, db=0) r.lpush('myqueue','myelement')
There are two main functions in Redis (HSET and HMSET) for adding fields to a hash key. Both functions are available in redis-py. Using HSET: import redis r = redis.StrictRedis(host='myserver', port=6379, db=0) r.hset('my_key', 'field0', 'value0') Using HMSET: import redis r = redis.St...
The redis-py client provides two classes StrictRedis and Redis to establish a basic connection to a Redis database. The Redis class is provided for backwards compatibility and new projects should use the StrictRedis class. One of the recommended ways to establish a connection, is to define the con...
You can establish a transaction by calling the pipeline method on the StrictRedis. Redis commands executed against the transaction are performed in a single block. # defaults to transaction=True tx = r.pipeline() tx.hincrbyfloat(debit_account_key, 'balance', -amount) tx.hincrbyfloat(credit_acc...
Redis-py provides the execute_command method to directly invoke Redis operations. This functionality can be used to access any modules that may not have a supported interface in the redis-py client. For example, you can use the execute_command to list all of the modules loaded into a Redis server:...

Page 1 of 1