public static void hRemoveDim(String key, String item){
ArrayList items = new ArrayList<>();
// 模糊查询出准确的item
redisTemplate.execute(new RedisCallback() {
@Override
public Object doInRedis(RedisConnection connection) throws DataAccessException {
Cursor> entryCursor = connection.hScan(key.getBytes(), ScanOptions.scanOptions().match("*" + item + "*").count(1000).build());
while(entryCursor.hasNext()){
Map.Entry next = entryCursor.next();
String key = new String(next.getKey());
// 将查询出的item放入list
items.add(key);
}
connection.close();
return null;
}
});
// 批量删除对应key中的item
redisTemplate.opsForHash().delete(key, item)
}
注意:本文归作者所有,未经作者允许,不得转载