From 3ef44331e3bd3e8b61513c88b7439631f49f05c7 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期二, 14 五月 2024 17:00:07 +0800
Subject: [PATCH] zjh 2024/05/14-1

---
 ltkj-system/src/main/java/com/ltkj/tduck/utils/CacheUtils.java |  266 ++++++++++++++++++++++++++--------------------------
 1 files changed, 133 insertions(+), 133 deletions(-)

diff --git a/ltkj-system/src/main/java/com/ltkj/tduck/utils/CacheUtils.java b/ltkj-system/src/main/java/com/ltkj/tduck/utils/CacheUtils.java
index 7f5c037..88470c7 100644
--- a/ltkj-system/src/main/java/com/ltkj/tduck/utils/CacheUtils.java
+++ b/ltkj-system/src/main/java/com/ltkj/tduck/utils/CacheUtils.java
@@ -1,133 +1,133 @@
-package com.ltkj.tduck.utils;
-
-import cn.hutool.core.convert.Convert;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.compress.utils.Lists;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.Cache;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.cache.ehcache.EhCacheCacheManager;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-/**
- * @author : tduck
- * @description : 鍩轰簬ehcache瀹炵幇
- * @create :  2022/01/06 10:40
- **/
-@Component
-@Slf4j
-@EnableCaching
-public class CacheUtils {
-    private final String ETERNAL_CACHE_NAME = "eternal_cache";
-    private final String TEMP_CACHE_NAME = "temp_cache";
-    @Autowired
-    private EhCacheCacheManager cacheManager;
-
-    /**
-     * 淇濆瓨鍒癈ache
-     */
-    public void save(String key, String value) {
-        cacheManager.getCache(ETERNAL_CACHE_NAME).put(key, value);
-    }
-
-    /**
-     * 鑾峰彇
-     *
-     * @param key
-     */
-    public String get(String key) {
-        Cache.ValueWrapper valueWrapper = cacheManager.getCache(ETERNAL_CACHE_NAME).get(key);
-        if (ObjectUtil.isNotNull(valueWrapper) && ObjectUtil.isNotNull(valueWrapper.get())) {
-            return valueWrapper.get().toString();
-        }
-        return null;
-    }
-
-
-    /**
-     * 鑷
-     *
-     * @param key
-     * @param number
-     * @return
-     */
-    public Long incr(String key, Integer number) {
-        String v = get(key);
-        if (StrUtil.isBlank(v)) {
-            v = "0";
-        }
-        long finalValue = Convert.toLong(v) + number;
-        save(key, String.valueOf(finalValue));
-        return finalValue;
-    }
-
-
-    /**
-     * 娣诲姞鍒伴泦鍚堢紦瀛�
-     *
-     * @param key
-     * @param value
-     */
-    public void addList(String key, Object value) {
-        List coll = this.getList(key, Object.class);
-        coll.add(value);
-        cacheManager.getCache(TEMP_CACHE_NAME).put(key, JsonUtils.objToJson(coll));
-    }
-
-
-    /**
-     * 浠庨泦鍚堜腑绉婚櫎
-     *
-     * @param key
-     * @param value
-     */
-    public void removeList(String key, Object value) {
-        List coll = this.getList(key, Object.class);
-        coll.remove(value);
-        cacheManager.getCache(TEMP_CACHE_NAME).put(key, JsonUtils.objToJson(coll));
-    }
-
-    /**
-     * 鑾峰彇闆嗗悎
-     *
-     * @param key
-     */
-    public List getList(String key, Class classz) {
-        String v = get(key);
-        if (ObjectUtil.isNotNull(v)) {
-            return JsonUtils.jsonToList(v, classz.getClass());
-        }
-        return Lists.newArrayList();
-    }
-
-
-    /**
-     * 涓存椂淇濆瓨 榛樿5min
-     */
-    public void tempSave(String key, String value) {
-        cacheManager.getCache(TEMP_CACHE_NAME).put(key, value);
-    }
-
-    /**
-     * 鑾峰彇涓存椂瀛樺偍鍙橀噺
-     *
-     * @param key
-     */
-    public String getTemp(String key) {
-        Cache.ValueWrapper valueWrapper = cacheManager.getCache(TEMP_CACHE_NAME).get(key);
-        if (ObjectUtil.isNotNull(valueWrapper) && ObjectUtil.isNotNull(valueWrapper.get())) {
-            return valueWrapper.get().toString();
-        }
-        return null;
-    }
-
-    public void removeTemp(String key) {
-        cacheManager.getCache(TEMP_CACHE_NAME).evict(key);
-    }
-
-
-}
+//package com.ltkj.tduck.utils;
+//
+//import cn.hutool.core.convert.Convert;
+//import cn.hutool.core.util.ObjectUtil;
+//import cn.hutool.core.util.StrUtil;
+//import lombok.extern.slf4j.Slf4j;
+//import org.apache.commons.compress.utils.Lists;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.cache.Cache;
+//import org.springframework.cache.annotation.EnableCaching;
+//import org.springframework.cache.ehcache.EhCacheCacheManager;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.List;
+//
+///**
+// * @author : tduck
+// * @description : 鍩轰簬ehcache瀹炵幇
+// * @create :  2022/01/06 10:40
+// **/
+//@Component
+//@Slf4j
+//@EnableCaching
+//public class CacheUtils {
+//    private final String ETERNAL_CACHE_NAME = "eternal_cache";
+//    private final String TEMP_CACHE_NAME = "temp_cache";
+//    @Autowired
+//    private EhCacheCacheManager cacheManager;
+//
+//    /**
+//     * 淇濆瓨鍒癈ache
+//     */
+//    public void save(String key, String value) {
+//        cacheManager.getCache(ETERNAL_CACHE_NAME).put(key, value);
+//    }
+//
+//    /**
+//     * 鑾峰彇
+//     *
+//     * @param key
+//     */
+//    public String get(String key) {
+//        Cache.ValueWrapper valueWrapper = cacheManager.getCache(ETERNAL_CACHE_NAME).get(key);
+//        if (ObjectUtil.isNotNull(valueWrapper) && ObjectUtil.isNotNull(valueWrapper.get())) {
+//            return valueWrapper.get().toString();
+//        }
+//        return null;
+//    }
+//
+//
+//    /**
+//     * 鑷
+//     *
+//     * @param key
+//     * @param number
+//     * @return
+//     */
+//    public Long incr(String key, Integer number) {
+//        String v = get(key);
+//        if (StrUtil.isBlank(v)) {
+//            v = "0";
+//        }
+//        long finalValue = Convert.toLong(v) + number;
+//        save(key, String.valueOf(finalValue));
+//        return finalValue;
+//    }
+//
+//
+//    /**
+//     * 娣诲姞鍒伴泦鍚堢紦瀛�
+//     *
+//     * @param key
+//     * @param value
+//     */
+//    public void addList(String key, Object value) {
+//        List coll = this.getList(key, Object.class);
+//        coll.add(value);
+//        cacheManager.getCache(TEMP_CACHE_NAME).put(key, JsonUtils.objToJson(coll));
+//    }
+//
+//
+//    /**
+//     * 浠庨泦鍚堜腑绉婚櫎
+//     *
+//     * @param key
+//     * @param value
+//     */
+//    public void removeList(String key, Object value) {
+//        List coll = this.getList(key, Object.class);
+//        coll.remove(value);
+//        cacheManager.getCache(TEMP_CACHE_NAME).put(key, JsonUtils.objToJson(coll));
+//    }
+//
+//    /**
+//     * 鑾峰彇闆嗗悎
+//     *
+//     * @param key
+//     */
+//    public List getList(String key, Class classz) {
+//        String v = get(key);
+//        if (ObjectUtil.isNotNull(v)) {
+//            return JsonUtils.jsonToList(v, classz.getClass());
+//        }
+//        return Lists.newArrayList();
+//    }
+//
+//
+//    /**
+//     * 涓存椂淇濆瓨 榛樿5min
+//     */
+//    public void tempSave(String key, String value) {
+//        cacheManager.getCache(TEMP_CACHE_NAME).put(key, value);
+//    }
+//
+//    /**
+//     * 鑾峰彇涓存椂瀛樺偍鍙橀噺
+//     *
+//     * @param key
+//     */
+//    public String getTemp(String key) {
+//        Cache.ValueWrapper valueWrapper = cacheManager.getCache(TEMP_CACHE_NAME).get(key);
+//        if (ObjectUtil.isNotNull(valueWrapper) && ObjectUtil.isNotNull(valueWrapper.get())) {
+//            return valueWrapper.get().toString();
+//        }
+//        return null;
+//    }
+//
+//    public void removeTemp(String key) {
+//        cacheManager.getCache(TEMP_CACHE_NAME).evict(key);
+//    }
+//
+//
+//}

--
Gitblit v1.8.0