| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * hash 删除操作 |
| | | * |
| | | * @param key 键 |
| | | * @param valueKey 值 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public boolean hashDel(String key, Object... valueKey) { |
| | | try { |
| | | redisTemplate.opsForHash().delete(key,valueKey); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * hash 设置hashMapt操作 |
| | | * |
| | | * @param key 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public boolean hashSetMap(String key, Map<String,Object> map) { |
| | | try { |
| | | redisTemplate.opsForHash().putAll(key, map); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * hash 设置单个hashMap操作 |
| | | * |
| | | * @param key 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public boolean hashSet(String hashKey, String key, Object value) { |
| | | try { |
| | | redisTemplate.opsForHash().put(hashKey,key,value); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * hash 获取整个hashKey数据 |
| | | * |
| | | * @param hashKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Map<Object, Object> hashGetAll(String hashKey) { |
| | | try { |
| | | return redisTemplate.opsForHash().entries(hashKey); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * hash 获取单个hashKey |
| | | * |
| | | * @param hashKey 键 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | public Object hashGet(String hashKey,String key) { |
| | | try { |
| | | return redisTemplate.opsForHash().get(hashKey,key); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | } |