初始化字典数据至内存
This commit is contained in:
@@ -3,6 +3,7 @@ package com.njcn.redis.utils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
@@ -79,6 +80,17 @@ public class RedisUtil {
|
||||
redisTemplate.delete(Arrays.asList(keys));
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定字符模糊匹配,批量删除keys
|
||||
*/
|
||||
public void deleteKeysByString(String str) {
|
||||
Set<String> keys = redisTemplate.keys(str.concat("*"));
|
||||
// 删除所有匹配的key
|
||||
if (keys != null && !keys.isEmpty()) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取key对应的字符数据
|
||||
|
||||
Reference in New Issue
Block a user