Package cn.com.anysdk.redis.reconnect
Class ExponentialBackoffReconnectStrategy
java.lang.Object
cn.com.anysdk.redis.reconnect.ExponentialBackoffReconnectStrategy
- All Implemented Interfaces:
RedisReconnectStrategy
指数退避重连策略
每次重试的等待时间会按指数增长,直到达到最大等待时间
-
Constructor Summary
ConstructorsConstructorDescriptionExponentialBackoffReconnectStrategy(long initialIntervalMs, long maxIntervalMs, double multiplier, int maxRetryCount) 创建指数退避重连策略 -
Method Summary
Modifier and TypeMethodDescriptionint获取最大重试次数getName()获取策略名称longgetNextWaitTime(int retryCount) 获取下一次重连的等待时间(毫秒)voidreset()重置重连策略状态
-
Constructor Details
-
ExponentialBackoffReconnectStrategy
public ExponentialBackoffReconnectStrategy(long initialIntervalMs, long maxIntervalMs, double multiplier, int maxRetryCount) 创建指数退避重连策略- Parameters:
initialIntervalMs- 初始等待时间(毫秒)maxIntervalMs- 最大等待时间(毫秒)multiplier- 等待时间增长倍数maxRetryCount- 最大重试次数,-1表示无限重试
-
-
Method Details
-
getNextWaitTime
public long getNextWaitTime(int retryCount) Description copied from interface:RedisReconnectStrategy获取下一次重连的等待时间(毫秒)- Specified by:
getNextWaitTimein interfaceRedisReconnectStrategy- Parameters:
retryCount- 当前重试次数- Returns:
- 等待时间(毫秒)
-
getMaxRetryCount
public int getMaxRetryCount()Description copied from interface:RedisReconnectStrategy获取最大重试次数- Specified by:
getMaxRetryCountin interfaceRedisReconnectStrategy- Returns:
- 最大重试次数,-1表示无限重试
-
reset
public void reset()Description copied from interface:RedisReconnectStrategy重置重连策略状态- Specified by:
resetin interfaceRedisReconnectStrategy
-
getName
Description copied from interface:RedisReconnectStrategy获取策略名称- Specified by:
getNamein interfaceRedisReconnectStrategy- Returns:
- 策略名称
-