【发布时间】:2018-10-18 18:43:25
【问题描述】:
我有一个带有 spring-data-redis (1.8.7) 和 jedis (2.9.0) 的 Spring 4.3.9 应用程序。我可以使用以下代码轻松设置和检索 ZSET:
// Commented out -- but below line works fine too
// redisTemplate.opsForZSet().remove("score", userId);
Double scoreInRedis = redisTemplate.opsForZSet().score("score", userId);
redisTemplate.opsForZSet().add("score", userId, (double) score);
但是,当我转到 redis CLI 并尝试使用“score”键检索 ZSET 时,我没有得到任何返回。所以我尝试了以下命令:
ZCARD "score" <-- this should give number of items wi
(integer) 0
ZSCORE "score" userId <--> I use the actual number here for the userId
(nil)
ZREVRANGE 或 ZREVRANGEBYSCORE 等其他命令都返回 (nil)。
我知道我的密钥正在设置,因为“信息密钥空间”显示密钥之间的差异和过期时间正好为 1——这是我的分数 ZSET。如果我从 Spring 应用程序中删除 ZSET,则密钥和过期密钥的数量是相同的。所以我知道我的钥匙在某处。
老兄,我的 ZSET 呢??我如何通过 CLI 访问它?我可以轻松地继续开发而无需通过 CLI 访问,但我想了解我在哪里。
【问题讨论】:
标签: spring redis jedis spring-data-redis