From fb3acc1ea0df99deb7c02b53440095ea0bd876d6 Mon Sep 17 00:00:00 2001 From: zhouxiang <zhouxiang> Date: 星期四, 24 三月 2022 17:32:45 +0800 Subject: [PATCH] 更新redisUtil的hashMap命令 --- src/main/java/com/hx/redis/RedisUtil.java | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/hx/redis/RedisUtil.java b/src/main/java/com/hx/redis/RedisUtil.java index 0861d12..f4cf4ed 100644 --- a/src/main/java/com/hx/redis/RedisUtil.java +++ b/src/main/java/com/hx/redis/RedisUtil.java @@ -1,10 +1,14 @@ package com.hx.redis; +import org.junit.Before; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; +import redis.clients.jedis.Jedis; import javax.annotation.Resource; import java.util.Date; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.TimeUnit; @@ -127,5 +131,53 @@ } -} + /** + * 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; + } + } +} -- Gitblit v1.8.0