|
|
package com.yoho.yhmessage.wechat.cache;
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -38,7 +36,8 @@ public class WechatCache { |
|
|
//模板key
|
|
|
String templateKey = KeyBuilder.getWechatTemplateKey(templateType);
|
|
|
//先从缓存中取
|
|
|
WechatTemplate wechatTemplate = redisValueCache.get(templateKey, WechatTemplate.class);
|
|
|
WechatTemplate wechatTemplate = null;// redisValueCache.get(templateKey,
|
|
|
// WechatTemplate.class);
|
|
|
//缓存为空从数据库取
|
|
|
if (null == wechatTemplate) {
|
|
|
wechatTemplate = wechatTemplateDao.selectByYhTemplateType(templateType);
|
...
|
...
|
@@ -47,7 +46,8 @@ public class WechatCache { |
|
|
return null;
|
|
|
}
|
|
|
//回填缓存数据
|
|
|
redisValueCache.set(templateKey, wechatTemplate, 7 * 24 * 60 * 60, TimeUnit.SECONDS);
|
|
|
// redisValueCache.set(templateKey, wechatTemplate, 7 * 24 * 60 *
|
|
|
// 60, TimeUnit.SECONDS);
|
|
|
logger.info("set wechatTemplate to cache {}", wechatTemplate);
|
|
|
}
|
|
|
return wechatTemplate;
|
...
|
...
|
|