| | |
| | | package com.ard.common.core.redis; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.BoundSetOperations; |
| | | import org.springframework.data.redis.core.HashOperations; |
| | |
| | | /** |
| | | * spring redis 工具类 |
| | | * |
| | | * @author ruoyi |
| | | * @author ard |
| | | **/ |
| | | @SuppressWarnings(value = { "unchecked", "rawtypes" }) |
| | | @Component |
| | |
| | | { |
| | | return redisTemplate.keys(pattern); |
| | | } |
| | | |
| | | /** |
| | | * 根据前缀获取所有的key* 例如:pro_ |
| | | */ |
| | | public List<Object> getListKey(String prefix) { |
| | | Set<Object> keys = redisTemplate.keys(prefix + "*"); |
| | | List<Object> values = redisTemplate.opsForValue().multiGet(keys); |
| | | return values; |
| | | } |
| | | /** |
| | | * 根据前缀获取所有的key* 例如:pro_ |
| | | */ |
| | | public Set<String> getSetKey(String prefix) { |
| | | Set<String> keys = redisTemplate.keys(prefix + "*"); |
| | | if (keys == null) return Collections.emptySet(); |
| | | return keys.stream().map(Object::toString).collect(Collectors.toSet()); |
| | | } |
| | | |
| | | |
| | | } |