| | |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.BoundSetOperations; |
| | | import org.springframework.data.redis.core.HashOperations; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.data.redis.core.*; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author ruoyi |
| | | **/ |
| | | @SuppressWarnings(value = {"unchecked" , "rawtypes"}) |
| | | @SuppressWarnings(value = {"unchecked", "rawtypes"}) |
| | | @Component |
| | | public class RedisCache { |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除缓存LIST中的某个数据 |
| | | * |
| | | * @param key Redis键 |
| | | * @param valueToRemove 需要删除的值 |
| | | * @return Long 大于0表示删除了几个,等于0表示没有删除,小于0表示在执行删除操作时发生了错误 |
| | | */ |
| | | public Long removeElementFromList(String key, String valueToRemove) { |
| | | ListOperations<String, String> listOps = redisTemplate.opsForList(); |
| | | Long remove = listOps.remove(key, 0, valueToRemove); |
| | | return remove; |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的基本对象列表 |
| | | * |
| | | * @param pattern 字符串前缀 |