// *號 必需要加,不然沒法模糊查詢
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());