From f537abe9f3646c739beaf15076246a2f71a347e9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 20 二月 2025 16:57:55 +0800
Subject: [PATCH] IOS广告增加区域屏蔽

---
 src/main/java/com/yeshi/buwan/util/RedisManager.java |   67 +++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/util/RedisManager.java b/src/main/java/com/yeshi/buwan/util/RedisManager.java
index 540d1c0..6266a64 100644
--- a/src/main/java/com/yeshi/buwan/util/RedisManager.java
+++ b/src/main/java/com/yeshi/buwan/util/RedisManager.java
@@ -9,6 +9,7 @@
 import com.google.gson.Gson;
 import com.yeshi.buwan.vo.video.VideoListResultVO;
 
+import org.yeshi.utils.SerializeUtil;
 import redis.clients.jedis.Jedis;
 import redis.clients.jedis.JedisPool;
 import redis.clients.jedis.params.SetParams;
@@ -93,6 +94,17 @@
         }
     }
 
+
+    public void increase(String key, int s) {
+        Jedis jedis = getJedis();
+        try {
+            jedis.incr(key);
+            jedis.expire(key, s);
+        } finally {
+            jedis.close();
+        }
+    }
+
     public void expire(String key, int seconds) {
         Jedis jedis = getJedis();
         try {
@@ -118,6 +130,10 @@
         removeKey(key);
     }
 
+    public void remove(String key) {
+        removeKey(key);
+    }
+
     /**
      * 淇濆瓨瑙嗛鏁版嵁
      *
@@ -126,7 +142,7 @@
      */
     public void saveVideoList(String key, VideoListResultVO videoData) {
         Gson gson = new Gson();
-        cacheCommonString(key, gson.toJson(videoData), 60 * 60 * 24);
+        cacheCommonString(key, gson.toJson(videoData), 60 * 60 * 8);
     }
 
     /**
@@ -197,4 +213,53 @@
             return true;
     }
 
+
+    /**
+     * 浠巖edis缂撳瓨涓煡璇紝鍙嶅簭鍒楀寲
+     *
+     * @param redisKey
+     * @return
+     */
+    public Object getDataFromRedis(String redisKey) {
+        //鏌ヨ
+        Jedis jedis = jedisPool.getResource();
+        try {
+            byte[] result = jedis.get(redisKey.getBytes());
+
+            //濡傛灉鏌ヨ娌℃湁涓虹┖
+            if (null == result) {
+                return null;
+            }
+
+            //鏌ヨ鍒颁簡锛屽弽搴忓垪鍖�
+            return SerializeUtil.unSerialize(result);
+        } finally {
+            jedis.close();
+        }
+    }
+
+    /**
+     * 灏嗘暟鎹簱涓煡璇㈠埌鐨勬暟鎹斁鍏edis
+     *
+     * @param redisKey
+     * @param obj
+     */
+    public void setDataToRedis(String redisKey, Object obj, Integer seconds) {
+
+        //搴忓垪鍖�
+        byte[] bytes = SerializeUtil.serialize(obj);
+
+        SetParams params = null;
+        if (seconds != null) {
+            params = new SetParams().nx().ex(seconds);
+        }
+        //瀛樺叆redis
+        Jedis jedis = jedisPool.getResource();
+        try {
+            jedis.set(redisKey.getBytes(), bytes, params);
+        } finally {
+            jedis.close();
+        }
+    }
+
 }

--
Gitblit v1.8.0