具有可自定义重试功能的redis clieht。
retry-redis的Python项目详细描述
重试redis
具有可自定义重试功能的redis clieht。
我为什么要建这个?
下面这样的redis异常可以通过简单的重试来处理。
这个软件包是为了帮助那些需要解决同样问题的人而设计的。
- redis.exceptions.connectionerror
- redis.exceptions.responseerror
- redis.exceptions.timeouterror
谁应该使用?
任何想和redis有重试逻辑的人。
如何安装
pip install retry-redis
如何使用
只需导入retry修饰的redis并使用它。
importloggingfromretry_redisimportRedislogging.basicConfig(level=logging.DEBUG)r=Redis(port=6666)r.lpush('list:test',1)# This log will be printed.# DEBUG:retry_redis.decorated_redis:Finished call to 'redis.client.Redis.lpush' after 0.002(s), this was the 1st time calling it.# DEBUG:retry_redis.decorated_redis:Finished call to 'redis.client.Redis.lpush' after 2.005(s), this was the 2nd time calling it.# DEBUG:retry_redis.decorated_redis:Finished call to 'redis.client.Redis.lpush' after 6.009(s), this was the 3rd time calling it.
包依赖性
- redis
- 韧性