用offer的形式放入延时队列,再用poll的形式取值。现在出现的现象是,有时候到过期时间,但是没有取到值,需要再次往里offer的时候才会取到值值。
//存的代码
RBlockingQueue
//取的代码:
while (true){
RBlockingQueue
//配置的集群模式 config.useClusterServers().setScanInterval(2000).addNodeAddress(newNodes.toArray(new String[0])) .setSubscriptionConnectionMinimumIdleSize(subscriptionConnectionMinimumIdleSize) .setSubscriptionConnectionPoolSize(subscriptionConnectionPoolSize) .setSubscriptionsPerConnection(subscriptionsPerConnection) .setClientName(clientName) .setRetryAttempts(retryAttempts) .setRetryInterval(retryInterval) .setTimeout(timeout) .setConnectTimeout(connectTimeout) .setIdleConnectionTimeout(idleConnectionTimeout) .setPassword(password) .setMasterConnectionPoolSize(masterConnectionPoolSize) .setMasterConnectionMinimumIdleSize(masterConnectionMinimumIdleSize) .setSlaveConnectionPoolSize(slaveConnectionPoolSize) .setSlaveConnectionMinimumIdleSize(slaveConnectionMinimumIdleSize);
//单点模式配置 config.useSingleServer().setAddress(address) .setConnectionMinimumIdleSize(connectionMinimumIdleSize) .setConnectionPoolSize(connectionPoolSize) .setDatabase(database) .setDnsMonitoringInterval(dnsMonitoringInterval) .setSubscriptionConnectionMinimumIdleSize(subscriptionConnectionMinimumIdleSize) .setSubscriptionConnectionPoolSize(subscriptionConnectionPoolSize) .setSubscriptionsPerConnection(subscriptionsPerConnection) .setClientName(clientName) .setRetryAttempts(retryAttempts) .setRetryInterval(retryInterval) .setTimeout(timeout) .setConnectTimeout(connectTimeout) .setIdleConnectionTimeout(idleConnectionTimeout) .setPassword(password);
redisson版本:3.11.4