wuxw
2022-11-16 39e3cd4fb4800dba43b3e09a79d0b6b424c5afa4
java110-utils/src/main/java/com/java110/utils/cache/CommonCache.java
old mode 100644 new mode 100755
@@ -1,5 +1,8 @@
package com.java110.utils.cache;
import com.java110.utils.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
/**
@@ -7,12 +10,15 @@
 */
public class CommonCache extends BaseCache {
    private final static Logger logger = LoggerFactory.getLogger(MappingCache.class);
    public final static int defaultExpireTime = 5 * 60;
    public final static int RESEND_DEFAULT_EXPIRETIME = 1 * 60;
    //支付默认回话
    public final static int PAY_DEFAULT_EXPIRE_TIME = 2 * 60 * 60;
    /**
     * 获取值(用户ID)
@@ -21,6 +27,8 @@
     */
    public static String getValue(String key) {
        Jedis redis = null;
        long startTime = DateUtil.getCurrentDate().getTime();
        try {
            redis = getJedis();
            return redis.get(key);
@@ -28,6 +36,7 @@
            if (redis != null) {
                redis.close();
            }
            logger.debug( key + " redis 耗时:" + (DateUtil.getCurrentDate().getTime() - startTime));
        }
    }
@@ -39,6 +48,8 @@
    public static String getAndRemoveValue(String key) {
        Jedis redis = null;
        String value = "";
        long startTime = DateUtil.getCurrentDate().getTime();
        try {
            redis = getJedis();
            value = redis.get(key);
@@ -47,6 +58,8 @@
            if (redis != null) {
                redis.close();
            }
            logger.debug( key + "getAndRemoveValue redis 耗时:" + (DateUtil.getCurrentDate().getTime() - startTime));
        }
        return value;
    }
@@ -70,6 +83,25 @@
    }
    /**
     * 保存数据
     *
     * @param key
     */
    public static void setValue(String key, String value) {
        Jedis redis = null;
        try {
            redis = getJedis();
            redis.set(key, value);
        } finally {
            if (redis != null) {
                redis.close();
            }
        }
    }
    /**
     * 删除记录
     *