//*号 必须要加,否则无法模糊查询
String prefix = "ofc-pincode-"+ pincode + "-*";
// 获取所有的key
Set<String> keys = redisTemplate.keys(prefix); // 批量获取数据
List<MyObject> myObjectListRedis = redisTemplate.opsForValue().multiGet(keys);
List<MyObject> myObjectList = JSON.parseArray(myObjectListRedis.toString(), MyObject.class);
log.info("myObjectList:{}",myObjectList.toString());
redis系列-RedisTemplate获取redis中以某些字符串为前缀的KEY列表
最新推荐文章于 2024-02-27 10:43:53 发布