|
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.time.Duration;
|
|
|
-import java.time.temporal.ChronoUnit;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
@@ -605,6 +605,21 @@ public class RedisUtil<K, V>{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 移除N个值为value
|
|
|
+ *
|
|
|
+ * @param pattern 键
|
|
|
+ * @return 移除的个数
|
|
|
+ */
|
|
|
+ public Set<String> keys(String pattern) {
|
|
|
+ try {
|
|
|
+ return redisTemplate.keys(pattern);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new HashSet<>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void expire(String key,Duration time){
|
|
|
redisTemplate.expire(key, time);
|
|
|
}
|