在实际项目中有时需要模糊查询redis,代码如下
public Set<String> getCacheKeys(String prex) {
try {
Set<String> keys = redisTemplate.keys(prex + "*");
return keys;
} catch (Exception e) {
return Collections.EMPTY_SET;
}
}