【问题标题】:Redis SCAN returns invalid cursorRedis SCAN 返回无效游标
【发布时间】:2020-08-29 17:57:24
【问题描述】:

在执行下面的代码时

KeyScanCursor<String> cursor = syncCommands.scan(ScanArgs.Builder.limit(50).match(match));
List<String> values = null;
while (!cursor.isFinished()) {
for (String key : cursor.getKeys()) {
    values = syncCommands.lrange(key, 0, 50);
    }
    cursor = syncCommands.scan(cursor, ScanArgs.Builder.limit(50).match(match));
}

得到空结果但在执行下面的命令时

redis-cli --cluster call 127.0.0.1:30001 SCAN 0 MATCH "orgId:EC:resetPasswordExpiryHours"

得到预期的结果

127.0.0.1:30003: 22
 orgId:EC:resetPasswordExpiryHours

有人可以帮我解释一下为什么上面的代码不起作用。

【问题讨论】:

    标签: java redis-cluster lettuce


    【解决方案1】:

    您的最后一次扫描迭代被忽略。光标已完成,但您尚未处理返回的键。

    【讨论】:

      猜你喜欢
      • 2021-02-03
      • 1970-01-01
      • 2014-12-10
      • 2015-03-22
      • 1970-01-01
      • 2016-08-23
      • 2021-05-14
      • 2021-01-12
      • 1970-01-01
      相关资源
      最近更新 更多