| | |
| | | package com.lf.server.service.all; |
| | | |
| | | import com.lf.server.entity.all.SettingData; |
| | | import com.lf.server.entity.ctrl.CountEntity; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | |
| | | */ |
| | | @Service("redisService") |
| | | public class RedisService { |
| | | @Autowired |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | /** |
| | |
| | | redisTemplate.delete(keys); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据Key获取List集合 |
| | | */ |
| | | public <T> List<T> getListByKey(String key) { |
| | | Object obj = get(key); |
| | | if (obj instanceof List<?>) { |
| | | return (List<T>) obj; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据Key保存数据 |
| | | */ |
| | | public <T> void saveListByKey(String key, List<T> list) { |
| | | if (null != list && list.size() > 0) { |
| | | put(key, list, SettingData.CACHE_EXPIRE, TimeUnit.MINUTES); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据Key保存数据 |
| | | */ |
| | | public <T> void saveListByKey(String key, List<T> list, Integer minutes) { |
| | | if (null != list && list.size() > 0) { |
| | | put(key, list, minutes, TimeUnit.MINUTES); |
| | | } |
| | | } |
| | | } |