old mode 100644
new mode 100755
| | |
| | | package com.java110.utils.cache; |
| | | |
| | | import com.java110.entity.mapping.Mapping; |
| | | import com.java110.dto.mapping.Mapping; |
| | | import com.java110.utils.constant.DomainContant; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.utils.util.SerializeUtil; |
| | | import redis.clients.jedis.Jedis; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | */ |
| | | public class MappingCache extends BaseCache { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(MappingCache.class); |
| | | |
| | | |
| | | //后缀 用来刷缓存时删除 所有以这个为后缀的数据 |
| | | public final static String _SUFFIX_MAPPING = "_SUFFIX_MAPPING"; |
| | | //日志 |
| | | public final static String LOG_SERVICE_CODE = "LOG_SERVICE_CODE"; |
| | | public final static String CALL_OUT_LOG = "CALL_OUT_LOG"; |
| | | |
| | | |
| | | /** |
| | | * 获取值 |
| | | * |
| | |
| | | */ |
| | | public static String getValue(String domain, String key) { |
| | | Jedis redis = null; |
| | | long startTime = DateUtil.getCurrentDate().getTime(); |
| | | try { |
| | | redis = getJedis(); |
| | | Object object = SerializeUtil.unserialize(redis.get((domain + key + _SUFFIX_MAPPING).getBytes())); |
| | |
| | | if (redis != null) { |
| | | redis.close(); |
| | | } |
| | | |
| | | logger.debug(domain + "::" + key + " redis 耗时:" + (DateUtil.getCurrentDate().getTime() - startTime)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | public static Mapping getMapping(String key) { |
| | | Jedis redis = null; |
| | | long startTime = DateUtil.getCurrentDate().getTime(); |
| | | |
| | | try { |
| | | redis = getJedis(); |
| | | Object obj = SerializeUtil.unserialize(redis.get((DomainContant.COMMON_DOMAIN + key + _SUFFIX_MAPPING).getBytes())); |
| | |
| | | if (redis != null) { |
| | | redis.close(); |
| | | } |
| | | logger.debug( key + " redis 耗时:" + (DateUtil.getCurrentDate().getTime() - startTime)); |
| | | |
| | | } |
| | | return null; |
| | | } |