一、数据库基本命令
1. 扫描所有数据表
scan 0
2. 扫描hash表Real_Gps中的两条记录
HSCAN Real_Gps 0 MATCH * COUNT 2
二、RedisTemplate操作scan
//1. 一次性获取Real_Gps中数据
Map<Object, Object> map1 =redisTemplate.opsForHash().entries(env.getProperty("Real_Gps"));
//2. 使用Scan方式遍历获取Real_Gps中的数据
ScanOptions scanOptions = ScanOptions.scanOptions().count(1).match("*").build();
Cursor<Entry<Object, Object>> cursor = redisTemplate.opsForHash().scan("Real_Gps", scanOptions);
while(cursor.hasNext()) {
Map.Entry<Object, Object> entry = cursor.next();
entry.getKey();
entry.getValue();
}
本文介绍了如何在Redis中使用基本命令进行数据扫描,并通过RedisTemplate实现数据的一次性获取及使用Scan方式进行高效遍历。
3万+

被折叠的 条评论
为什么被折叠?



