rvrdata.adapters.redis
Adapter for accessing Redis databases.
class RvrdataRedis
Data adapter for Redis databases.
Redis is an extremely flexible caching database. It typically runs in-memory and as a result is very fast for working with data.
This adapter exposes most redist commands allowing for data to be set and retrieved as needed from local or remote redis databases.
https://realpython.com/python-redis/
Use databases and namespaces
It should be noted that redis provides a shared resource. To avoid conflicts due to overlapping keys, it is highly recommended that separate databases be used along with namespaces that have unique names. The database is set using the db parameter. The hash commands can be used to create namespaces including the commands hset, hget, and hdel.
Consider cache eviction strategy
To maintain an effective cache and good performance, data may need to be removed if it is no longer needed. There are many strategies to do this including setting expiry times or calling dump commands.
connect()
Connect redis client to database.
This method is called automatically any time a redis action is run.
There are a series of reserved keywords for the redis clients. The most common are the following defaults:
- host: localhost
- port: 6379
- db: 0
- decode_responses: True
Other notable keywords include username and password. For a full list, see the Redis class in redis client
run_cmd()
Execute redis command.
This adapter supports most redis commands. For a full listing, see the list of commands
Redis Metrics
The following metrics are included in the step results:
- rvrdata.dataflow.action.redis.function.action_count: Number of times the redis function is called (int).
One row is added to the metrics each time the action is run.
force_pass()
Fake successful action that does nothing.
See force_pass
in stdout adapter.