From 2ed1199d48f7207f4a012c04f61e13ac1a8d5154 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期四, 16 六月 2022 10:27:44 +0800
Subject: [PATCH] 新增请求安全工具

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

diff --git a/src/main/java/com/hx/redis/RedisUtil.java b/src/main/java/com/hx/redis/RedisUtil.java
index 27b676c..8067593 100644
--- a/src/main/java/com/hx/redis/RedisUtil.java
+++ b/src/main/java/com/hx/redis/RedisUtil.java
@@ -4,6 +4,7 @@
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
@@ -321,7 +322,7 @@
      * @param end 缁撴潫浣嶇疆,-1杩斿洖鎵�鏈�
      * @return true鎴愬姛 false 澶辫触
      */
-    public Object listGetRange(String key, long start , long end) {
+    public List<Object> listGetRange(String key, long start , long end) {
         try {
             return redisTemplate.opsForList().range(key, start, end);
         } catch (Exception e) {
@@ -362,4 +363,19 @@
         }
     }
 
+    /**
+     * @param key     閿�
+     * @param value   鍊�
+     * @param timeOut 鏃堕棿
+     * @param unit    鏃堕棿鍗曚綅
+     */
+    public Boolean setIfAbsent(String key, Object value, long timeOut, TimeUnit unit) {
+        try {
+            return redisTemplate.opsForValue().setIfAbsent(key, value, timeOut, unit);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
 }

--
Gitblit v1.8.0