Commit 1f4da4de authored by liaozan's avatar liaozan 🏀

Add keys operation

parent 257d661d
...@@ -162,10 +162,7 @@ public class CacheUtils { ...@@ -162,10 +162,7 @@ public class CacheUtils {
} }
/** /**
* keys * 模糊搜索 key
*
* @param pattern
* @return
*/ */
public static Set<String> keys(String pattern) { public static Set<String> keys(String pattern) {
return getCacheProvider().keys(pattern); return getCacheProvider().keys(pattern);
......
...@@ -13,7 +13,6 @@ import org.springframework.core.env.Environment; ...@@ -13,7 +13,6 @@ import org.springframework.core.env.Environment;
import java.time.Duration; import java.time.Duration;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.stream.Collectors;
/** /**
* @author liaozan * @author liaozan
...@@ -66,12 +65,7 @@ public class CacheProviderDelegate implements CacheProvider { ...@@ -66,12 +65,7 @@ public class CacheProviderDelegate implements CacheProvider {
@Override @Override
public Set<String> keys(String pattern) { public Set<String> keys(String pattern) {
Set<String> keys = getCacheProvider().keys(withKeyPrefix(pattern)); Set<String> keys = getCacheProvider().keys(withKeyPrefix(pattern));
return keys.stream().map(e->{ return StreamUtils.toSet(keys, this::removeKeyPrefix);
if(StringUtils.isBlank(prefixWithDelimiter)){
return e;
}
return e.replaceFirst(prefixWithDelimiter,"");
}).collect(Collectors.toSet());
} }
@Override @Override
......
...@@ -71,10 +71,7 @@ public class RedisCacheProvider implements CacheProvider { ...@@ -71,10 +71,7 @@ public class RedisCacheProvider implements CacheProvider {
} }
/** /**
* 模糊搜索KEY * 模糊搜索 key
*
* @param pattern
* @return
*/ */
@Override @Override
public Set<String> keys(String pattern) { public Set<String> keys(String pattern) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment