sun27
@Component
public class RedisDBChangeUtil {
@Autowired
private StringRedisTemplate redisTemplate;

public void setDataBase(int num) {
LettuceConnectionFactory connectionFactory = (LettuceConnectionFactory) redisTemplate.getConnectionFactory();
if (connectionFactory != null && num != connectionFactory.getDatabase()) {
connectionFactory.setDatabase(num);
connectionFactory.afterPropertiesSet();
this.redisTemplate.setConnectionFactory(connectionFactory);
connectionFactory.resetConnection();
}
}
}

redis单线程为什么那么快:
  • 纯内存操作
  • 使用IO多路复用技术
  • 非CPU密集型任务

分类:

技术点:

相关文章:

  • 2022-02-07
  • 2022-01-22
  • 2021-12-22
  • 2021-04-30
猜你喜欢
  • 2022-02-07
  • 2022-02-07
  • 2021-11-17
  • 2022-02-07
  • 2021-09-22
  • 2022-02-07
相关资源
相似解决方案