From a48817ffcb840ed803c813c010f3730eb7e9cb87 Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期三, 06 四月 2022 15:52:01 +0800 Subject: [PATCH] 优化 --- src/main/java/com/hx/redis/RedisUtil.java | 35 +++++++++++++++++++++++++++++++---- 1 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hx/redis/RedisUtil.java b/src/main/java/com/hx/redis/RedisUtil.java index f4cf4ed..dbcfa16 100644 --- a/src/main/java/com/hx/redis/RedisUtil.java +++ b/src/main/java/com/hx/redis/RedisUtil.java @@ -1,13 +1,9 @@ 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; @@ -180,4 +176,35 @@ 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