Spring Data Redis 在 TTL 到期后不清理辅助地理空间索引

Spring Data Redis does not clean up secondary Geospatial Index after TTL expiry

使用以下模型:

@RedisHash("positions")
public class Position {

    @Id
    private String id;

    @GeoIndexed
    private Point coordinates;

    @TimeToLive(unit = TimeUnit.MINUTES)
    protected int ttl;

    //...
}

我注意到一些数据在 Time To Live 过期后仍然存在。注意过期事件前后 keys * 命令的区别:

之前

127.0.0.1:6379> keys *
1) "positions:336514e6-3e52-487a-a88b-98b110ec1c28"
2) "positions:coordinates"
3) "positions:336514e6-3e52-487a-a88b-98b110ec1c28:idx"
4) "positions"
5) "positions:336514e6-3e52-487a-a88b-98b110ec1c28:phantom"

之后

127.0.0.1:6379> keys *
1) "positions:coordinates"
2) "positions:336514e6-3e52-487a-a88b-98b110ec1c28:idx"
3) "positions"
4) "positions:336514e6-3e52-487a-a88b-98b110ec1c28:phantom"

只删除了 positions:336514e6-3e52-487a-a88b-98b110ec1c28 项。

我还注意到,再过一段时间后,*:phantom 项也被删除了,但其余的没有。这是一个错误还是需要 configure/implement 更多内容?

您的应用程序需要保持活跃。 Redis 存储库使用键空间事件来获取有关过期的通知,因此 Spring Data Redis 可以清理索引结构。 Redis 仅支持顶级键的过期,不支持 list/set 个元素的过期。

:phantom 密钥的有效期稍长,这就是它在原始密钥过期后过期的原因。它用于为索引清理等提供过期哈希值。