【发布时间】:2020-10-02 01:40:09
【问题描述】:
当我使用 springboot 时,我使用 redis 作为我的缓存服务器。 但是我看了spring-data-redis源码,当evict cache时,代码是
byte[][] keys = Optional.ofNullable(connection.keys(pattern)).orElse(Collections.emptySet())
.toArray(new byte[0][]);
Redis 建议将 keys 命令替换为 scan 命令。为什么春天的团队不这样做。
【问题讨论】:
-
非常好的问题。 KEYS 命令无法扩展,在我们的应用程序中,缓存驱逐已成为瓶颈,KEYS 需要 160 毫秒,这会阻塞所有其他 redis 命令,因此缓存驱逐实质上会阻塞整个分布式应用程序集群。
标签: spring-boot redis spring-data-redis