【发布时间】:2017-06-15 22:34:57
【问题描述】:
我正在尝试使用 Lettuce 的同步命令进行 HSCAN。问题是我无法弄清楚初始化 MapScanCursor 的正确方法。我的构造函数没有成功,MapScanCursor.INITIAL 给出了ScanCursor 类型(也没有运气将其转换为MapScanCursor)。
这是一个例子:
RedisClient redisClient = RedisClient.create("redis://" + url + ":" + port);
RedisHashCommands<String, String> redisCommands = redisClient.connect().sync();
List<String> fields = new LinkedList<>();
MapScanCursor<String, String> scanCursor = ?
do {
scanCursor = redisCommands.hscan(key, scanCursor);
fields.addAll(scanCursor.getMap().keySet());
} while (!scanCursor.isFinished());
我应该如何初始化“scanCursor”?
【问题讨论】: