From a84b57832d20053cd5bc5a41f5284f7108d9a722 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期四, 31 三月 2022 15:25:56 +0800
Subject: [PATCH] Merge branch 'master' of http://1.15.4.62/r/~chenjiahe/hx_common

---
 src/main/java/com/hx/redis/RedisUtil.java |   83 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 81 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/hx/redis/RedisUtil.java b/src/main/java/com/hx/redis/RedisUtil.java
index 0861d12..dbcfa16 100644
--- a/src/main/java/com/hx/redis/RedisUtil.java
+++ b/src/main/java/com/hx/redis/RedisUtil.java
@@ -4,7 +4,7 @@
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.util.Date;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 
@@ -127,5 +127,84 @@
 
     }
 
-}
 
+    /**
+     * 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;
+        }
+    }
+
+}

--
Gitblit v1.8.0