【问题标题】:How to clear Redis cache using Redission when Redis deployed to 2 or more containers?Redis部署到2个或更多容器时如何使用Redission清除Redis缓存?
【发布时间】:2021-02-14 17:50:21
【问题描述】:

在我的 Spring Boot 项目中,我在 Docker swarm 集群中部署了一个 redis 容器。我将它用作应用程序的 Hibernate 二级缓存。我使用 Redisson 客户端使用以下代码手动清除缓存

Config config = new Config();
config.useSingleServer().setAddress("redis://" + redisProperties.getHost() + ":" + redisProperties.getPort());
RedissonClient redisson = Redisson.create(config);
redisson.getKeys().flushdb();
redisson.shutdown();

现在我想将它扩展到多个容器以对请求进行负载平衡。如果这样做,如何同时清除 2 个或更多容器中的缓存?

【问题讨论】:

    标签: java spring spring-boot redis redisson


    【解决方案1】:

    基于Redisson作者response,清除一个容器中的缓存,清除所有容器中的缓存

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-16
      • 2016-09-10
      • 2019-12-08
      • 2018-10-25
      • 2017-02-10
      • 1970-01-01
      相关资源
      最近更新 更多