Authored by hugufei

缓存优化

Showing 20 changed files with 277 additions and 149 deletions
... ... @@ -3,14 +3,25 @@ package com.yoho.search.common.cache.impls;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.common.cache.model.CacheObject;
import java.util.BitSet;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public interface CacheInterface {
public void addOrUpdate(RedisKeyBuilder redisKeyBuilder, CacheObject value, int expiredTimeInMinute);
public boolean exist(RedisKeyBuilder redisKeyBuilder);
public void delete(RedisKeyBuilder redisKeyBuilder);
public CacheObject get(RedisKeyBuilder redisKeyBuilder);
public void addOrUpdate(RedisKeyBuilder redisKeyBuilder, CacheObject value, int expiredTimeInMinute);
public void mutiSet(final Map<RedisKeyBuilder,String> map, final int expiredTimeInMinute);
public List<String> mutiGet(Collection<RedisKeyBuilder> redisKeyBuilders) ;
public boolean setBitSet(RedisKeyBuilder redisKeyBuilder, BitSet bitSet, int expiredTimeInMinute);
public Map<Integer, Boolean> getFromBitSet(RedisKeyBuilder key, List<Integer> offsets);
}
... ...
package com.yoho.search.common.cache.impls;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.common.cache.model.CacheObject;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import net.sf.ehcache.Statistics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.yoho.search.common.cache.model.CacheObject;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.io.InputStream;
import java.util.*;
@Service("ehCache")
public class EhCache implements CacheInterface {
... ... @@ -67,15 +61,6 @@ public class EhCache implements CacheInterface {
}
@Override
public void delete(RedisKeyBuilder redisKeyBuilder) {
try {
cache.remove(redisKeyBuilder.getKey());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Override
public CacheObject get(RedisKeyBuilder redisKeyBuilder) {
try {
Element e = cache.get(redisKeyBuilder.getKey());
... ... @@ -91,12 +76,13 @@ public class EhCache implements CacheInterface {
return this.get(redisKeyBuilder) == null ? false : true;
}
public void mutiSet(final Map<RedisKeyBuilder,String> map, final int timeoutInSecond) {
@Override
public void mutiSet(final Map<RedisKeyBuilder,String> map, final int expiredTimeInMinute) {
try {
Collection<Element> elements = new ArrayList<>();
for (Map.Entry<RedisKeyBuilder, ? extends String> entry: map.entrySet()) {
Element element = new Element(entry.getKey().getKey(), entry.getValue());
element.setTimeToLive(timeoutInSecond);
element.setTimeToLive(expiredTimeInMinute * 60);
elements.add(element);
}
cache.putAll(elements);
... ... @@ -105,6 +91,7 @@ public class EhCache implements CacheInterface {
}
}
@Override
public List<String> mutiGet(Collection<RedisKeyBuilder> redisKeyBuilders) {
Collection<String> keys = new ArrayList<>();
for (RedisKeyBuilder redisKeyBuilder:redisKeyBuilders) {
... ... @@ -121,6 +108,37 @@ public class EhCache implements CacheInterface {
}
}
return values;
}
@Override
public boolean setBitSet(RedisKeyBuilder redisKeyBuilder, BitSet bitSet, int expiredTimeInMinute) {
try {
Element element = new Element(redisKeyBuilder.getKey(),bitSet);
element.setTimeToLive(expiredTimeInMinute * 60);
cache.put(element);
return true;
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
}
@Override
public Map<Integer, Boolean> getFromBitSet(RedisKeyBuilder key, List<Integer> offsets){
try {
Element e = this.cache.get(key.getKey());
if(e==null){
return null;
}
BitSet cacheBitSet = (BitSet)e.getObjectValue();
Map<Integer, Boolean> results = new HashMap<>();
for (Integer offset:offsets) {
results.put(offset,cacheBitSet.get(offset));
}
return results;
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
}
}
}
... ...
... ... @@ -11,56 +11,86 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.BitSet;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@Service("searchRedis")
public class SearchRedis implements CacheInterface {
private static final Logger logger = LoggerFactory.getLogger(SearchRedis.class);
private static final Logger logger = LoggerFactory.getLogger(SearchRedis.class);
@Autowired
private YohoSearchRedisComponent yohoSearchRedisComponent;
@Override
public boolean exist(RedisKeyBuilder redisKeyBuilder) {
try {
YHRedisTemplate redisTemplate = yohoSearchRedisComponent.getRedisTemplate();
return RedisCacheUtils.exist(redisTemplate, redisKeyBuilder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
}
@Autowired
private YohoSearchRedisComponent yohoSearchRedisComponent;
@Override
public CacheObject get(RedisKeyBuilder redisKeyBuilder) {
try {
YHValueOperations valueOperations = yohoSearchRedisComponent.getValueOperations();
return RedisCacheUtils.get(valueOperations, redisKeyBuilder, CacheObject.class);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
}
}
@Override
public CacheObject get(RedisKeyBuilder redisKeyBuilder) {
try {
YHValueOperations valueOperations = yohoSearchRedisComponent.getValueOperations();
return RedisCacheUtils.get(valueOperations, redisKeyBuilder, CacheObject.class);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
}
}
@Override
public void addOrUpdate(RedisKeyBuilder redisKeyBuilder, CacheObject value, int expiredTimeInMinute) {
try {
YHValueOperations valueOperations = yohoSearchRedisComponent.getValueOperations();
RedisCacheUtils.add(valueOperations, redisKeyBuilder, value, expiredTimeInMinute);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Override
public void addOrUpdate(RedisKeyBuilder redisKeyBuilder, CacheObject value, int expiredTimeInMinute) {
try {
YHValueOperations valueOperations = yohoSearchRedisComponent.getValueOperations();
RedisCacheUtils.add(valueOperations, redisKeyBuilder, value, expiredTimeInMinute);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
@Override
public void mutiSet(Map<RedisKeyBuilder, String> map, int expiredTimeInMinute) {
YHRedisTemplate redisTemplate = yohoSearchRedisComponent.getRedisTemplate();
RedisCacheUtils.mutiSet(redisTemplate, map, expiredTimeInMinute);
}
}
@Override
public List<String> mutiGet(Collection<RedisKeyBuilder> redisKeyBuilders) {
YHValueOperations valueOperations = yohoSearchRedisComponent.getValueOperations();
return RedisCacheUtils.mutiGet(valueOperations, redisKeyBuilders);
}
@Override
public void delete(RedisKeyBuilder redisKeyBuilder) {
try {
YHRedisTemplate redisTemplate = yohoSearchRedisComponent.getRedisTemplate();
RedisCacheUtils.delete(redisTemplate, redisKeyBuilder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Override
public boolean setBitSet(RedisKeyBuilder redisKeyBuilder, BitSet bitSet, int expiredTimeInMinute) {
try {
return RedisCacheUtils.setBitSet(yohoSearchRedisComponent.getRedisTemplate(), redisKeyBuilder, bitSet, expiredTimeInMinute);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
}
@Override
public boolean exist(RedisKeyBuilder redisKeyBuilder) {
try {
YHRedisTemplate redisTemplate = yohoSearchRedisComponent.getRedisTemplate();
return RedisCacheUtils.exist(redisTemplate, redisKeyBuilder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
}
@Override
public Map<Integer, Boolean> getFromBitSet(RedisKeyBuilder key, List<Integer> offsets) {
try {
YHRedisTemplate redisTemplate = yohoSearchRedisComponent.getRedisTemplate();
if (!redisTemplate.hasKey(key)) {
return null;
}
return RedisCacheUtils.getBits(redisTemplate, key, offsets);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
}
}
}
... ...
... ... @@ -13,58 +13,88 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.BitSet;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 使用有货共用的不同步redis
*
* @author hugufei
*
* @author hugufei
*/
@Service("yohoRedis")
public class YohoRedis implements CacheInterface {
private static final Logger logger = LoggerFactory.getLogger(YohoRedis.class);
private static final Logger logger = LoggerFactory.getLogger(YohoRedis.class);
@Autowired
private YohoNoSyncRedisComponent yohoNoSyncRedisComponent;
@Override
public boolean exist(RedisKeyBuilder redisKeyBuilder) {
try {
return RedisCacheUtils.exist(yohoNoSyncRedisComponent.getRedisTemplate(), redisKeyBuilder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
}
@Override
public CacheObject get(RedisKeyBuilder redisKeyBuilder) {
try {
return RedisCacheUtils.get(yohoNoSyncRedisComponent.getValueOperations(), redisKeyBuilder, CacheObject.class);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
}
}
@Override
public void addOrUpdate(RedisKeyBuilder redisKeyBuilder, CacheObject value, int expiredTimeInMinute) {
try {
RedisCacheUtils.add(yohoNoSyncRedisComponent.getValueOperations(), redisKeyBuilder, value, expiredTimeInMinute);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Autowired
private YohoNoSyncRedisComponent yohoNoSyncRedisComponent;
@Override
public void mutiSet(Map<RedisKeyBuilder, String> map, int expiredTimeInMinute) {
YHRedisTemplate redisTemplate = yohoNoSyncRedisComponent.getRedisTemplate();
RedisCacheUtils.mutiSet(redisTemplate, map, expiredTimeInMinute);
}
@Override
public CacheObject get(RedisKeyBuilder redisKeyBuilder) {
try {
return RedisCacheUtils.get(yohoNoSyncRedisComponent.getValueOperations(), redisKeyBuilder, CacheObject.class);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
}
}
@Override
public void addOrUpdate(RedisKeyBuilder redisKeyBuilder, CacheObject value, int expiredTimeInMinute) {
try {
RedisCacheUtils.add(yohoNoSyncRedisComponent.getValueOperations(), redisKeyBuilder, value, expiredTimeInMinute);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Override
public List<String> mutiGet(Collection<RedisKeyBuilder> redisKeyBuilders) {
YHValueOperations valueOperations = yohoNoSyncRedisComponent.getValueOperations();
return RedisCacheUtils.mutiGet(valueOperations, redisKeyBuilders);
}
@Override
public void delete(RedisKeyBuilder redisKeyBuilder) {
try {
RedisCacheUtils.delete(yohoNoSyncRedisComponent.getRedisTemplate(), redisKeyBuilder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Override
public boolean setBitSet(RedisKeyBuilder redisKeyBuilder, BitSet bitSet, int expiredTimeInMinute) {
try {
return RedisCacheUtils.setBitSet(yohoNoSyncRedisComponent.getRedisTemplate(), redisKeyBuilder, bitSet, expiredTimeInMinute);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
}
@Override
public boolean exist(RedisKeyBuilder redisKeyBuilder) {
try {
return RedisCacheUtils.exist(yohoNoSyncRedisComponent.getRedisTemplate(), redisKeyBuilder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
}
@Override
public Map<Integer, Boolean> getFromBitSet(RedisKeyBuilder key, List<Integer> offsets) {
try {
if (!this.exist(key)) {
return null;
}
return RedisCacheUtils.getBits(yohoNoSyncRedisComponent.getRedisTemplate(), key, offsets);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
}
}
}
... ...
... ... @@ -5,9 +5,12 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yoho.core.redis.cluster.operations.nosync.YHRedisTemplate;
import com.yoho.core.redis.cluster.operations.nosync.YHValueOperations;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.base.utils.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
public class RedisCacheUtils {
... ... @@ -29,15 +32,51 @@ public class RedisCacheUtils {
}
valueOperations.set(redisKeyBuilder, compressedVal, expiredTimeInMinute, TimeUnit.MINUTES);
}
public static void delete(YHRedisTemplate redisTemplate, RedisKeyBuilder redisKeyBuilder) {
redisTemplate.delete(redisKeyBuilder);
}
public static boolean exist(YHRedisTemplate redisTemplate, RedisKeyBuilder redisKeyBuilder) {
return redisTemplate.hasKey(redisKeyBuilder);
}
public static void mutiSet(YHRedisTemplate redisTemplate, Map<RedisKeyBuilder, String> map, int expiredTimeInMinute) {
redisTemplate.mset(map, expiredTimeInMinute*60);
}
public static List<String> mutiGet(YHValueOperations valueOperations, Collection<RedisKeyBuilder> redisKeyBuilders) {
return valueOperations.multiGet(redisKeyBuilders);
}
/**
* 设置bitset-整个设置
* @param redisTemplate
* @param redisKeyBuilder
* @param bitSet
* @param expiredTimeInMinute
* @return
*/
public static boolean setBitSet(YHRedisTemplate redisTemplate, RedisKeyBuilder redisKeyBuilder, BitSet bitSet, int expiredTimeInMinute) {
return redisTemplate.setBits(redisKeyBuilder,bitSet,expiredTimeInMinute * 60);
}
/**
* 获取bitset
* @param redisTemplate
* @param redisKeyBuilder
* @param offsets
* @return
*/
public static Map<Integer, Boolean> getBits(YHRedisTemplate redisTemplate, RedisKeyBuilder redisKeyBuilder, List<Integer> offsets) {
List<Long> LongOffsets = CollectionUtils.toList(offsets,(a)->a.longValue());
Map<Long, Boolean> redisResults = redisTemplate.getBits(redisKeyBuilder,LongOffsets);
if(redisResults==null || redisResults.isEmpty()){
return null;
}
Map<Integer, Boolean> results = new HashMap<>();
for (Map.Entry<Long, Boolean> entry: redisResults.entrySet()) {
results.put(entry.getKey().intValue(),entry.getValue());
}
return results;
}
/**
* 序列化保持null值
*
... ...
... ... @@ -4,7 +4,7 @@ import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.base.utils.CollectionUtils;
import com.yoho.search.base.utils.Transfer;
import com.yoho.search.common.cache.impls.EhCache;
import com.yoho.search.core.redis.components.YohoSearchRedisComponent;
import com.yoho.search.common.cache.impls.SearchRedis;
import com.yoho.search.recall.scene.models.common.AbstractCacheRequestResponse;
import com.yoho.search.recall.scene.models.common.ICacheRequest;
import org.apache.commons.lang.StringUtils;
... ... @@ -19,9 +19,9 @@ public abstract class AbstractCacheBean<Request extends ICacheRequest, Response,
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
@Autowired
private YohoSearchRedisComponent yohoSearchRedisComponent;
@Autowired
private EhCache ehCache;
@Autowired
private SearchRedis searchRedis;
/**
* 批量处理请求,以及添加缓存
... ... @@ -170,7 +170,7 @@ public abstract class AbstractCacheBean<Request extends ICacheRequest, Response,
if(request==null){
return 0;
}
return request.cacheTimeInSecond();
return request.cacheTimeInMinute();
}
});
//2、按缓存时间大小直接加入缓存
... ... @@ -179,7 +179,7 @@ public abstract class AbstractCacheBean<Request extends ICacheRequest, Response,
}
}
private void batchAddResponseToCache(List<RequestResponse> requestResponses,int timeOutInSecond) {
private void batchAddResponseToCache(List<RequestResponse> requestResponses,int expiredTimeInMinute) {
try {
Map<RedisKeyBuilder, String> toCacheMap = new HashMap<>();
for (RequestResponse requestResponse : requestResponses) {
... ... @@ -205,7 +205,7 @@ public abstract class AbstractCacheBean<Request extends ICacheRequest, Response,
if (toCacheMap.isEmpty()) {
return;
}
this.batchAddToCache(toCacheMap, timeOutInSecond);
this.batchAddToCache(toCacheMap, expiredTimeInMinute);
} catch (Exception e) {
RECALL_NEW_LOGGER.error(e.getMessage(), e);
}
... ... @@ -215,15 +215,15 @@ public abstract class AbstractCacheBean<Request extends ICacheRequest, Response,
if (useEhCache()){
return ehCache.mutiGet(keys);
} else {
return yohoSearchRedisComponent.getValueOperations().multiGet(keys);
return searchRedis.mutiGet(keys);
}
}
private void batchAddToCache(Map<RedisKeyBuilder, String> toCacheMap,int timeOutInSecond) {
private void batchAddToCache(Map<RedisKeyBuilder, String> toCacheMap,int expiredTimeInMinute) {
if (useEhCache()) {
ehCache.mutiSet(toCacheMap, timeOutInSecond);
ehCache.mutiSet(toCacheMap, expiredTimeInMinute);
} else {
yohoSearchRedisComponent.getRedisTemplate().mset(toCacheMap, timeOutInSecond);
searchRedis.mutiSet(toCacheMap,expiredTimeInMinute);
}
}
... ...
... ... @@ -15,12 +15,12 @@ public interface IStrategy {
String strategyCacheKey();// 可用于缓存的key
int cacheTimeInSecond();//缓存时间
int cacheTimeInMinute();//缓存时间
default StringBuilder defaultStrategyKey(){
StringBuilder sb = new StringBuilder();
sb.append(this.strategtEnum().name());
sb.append(this.cacheTimeInSecond());
sb.append(this.cacheTimeInMinute());
sb.append(this.size());
return sb;
}
... ...
... ... @@ -43,7 +43,7 @@ public class CommonAddFlowStrategy implements IStrategy {
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
... ...
... ... @@ -43,7 +43,7 @@ public class CommonDirectTrainStrategy implements IStrategy {
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
... ...
... ... @@ -48,7 +48,7 @@ public class CommonFirstSknStrategy implements IStrategy {
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
... ...
... ... @@ -43,7 +43,7 @@ public class CommonHeatValueStrategy implements IStrategy {
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
... ...
... ... @@ -43,7 +43,7 @@ public class CommonNewShopStrategy implements IStrategy {
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME;
}
... ...
... ... @@ -43,7 +43,7 @@ public class RecommendSknStrategy implements IStrategy {
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.RECOMMEND_SKN_CACHE_TIME;
}
... ...
... ... @@ -21,7 +21,7 @@ public abstract class SortBrandAbstractStrategy implements IStrategy {
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.SORT_BRAND_RECALL_STRATEGY_CACHE_TIME;
}
... ...
... ... @@ -7,27 +7,27 @@ package com.yoho.search.recall.scene.constants;
public class CacheTimeConstants {
//通用召回的缓存 - 10分钟
public static final int COMMON_RECALL_STRATEGY_CACHE_TIME = 10 * 60;
public static final int COMMON_RECALL_STRATEGY_CACHE_TIME = 10 ;
//SKN的的缓存 - 60分钟
public static final int RECOMMEND_SKN_CACHE_TIME = 60 * 60;
public static final int RECOMMEND_SKN_CACHE_TIME = 60 ;
//品类+品牌的缓存 - 60分钟
public static final int SORT_BRAND_RECALL_STRATEGY_CACHE_TIME = 60 * 60;
public static final int SORT_BRAND_RECALL_STRATEGY_CACHE_TIME = 60 ;
//SKN基本信息的缓存-一个小时
public static final int SKN_BASE_INFO = 60 * 60;
public static final int SKN_BASE_INFO = 60 ;
//SKN返回信息的缓存 - 10分钟
public static final int SKN_RETURN_INFO = 10 * 60;
public static final int SKN_RETURN_INFO = 10 ;
//用户召回结果的缓存-三分钟
public static final int USER_RECALL_SKN_LIST = 3 * 60;
public static final int USER_RECALL_SKN_LIST = 3 ;
//页面skn的bitset缓存
public static final int PAGE_SKN_BITSET = 60 * 60;
public static final int PAGE_SKN_BITSET = 60 ;
//页面个性化因子的缓存
public static final int PAGE_PERSIONAL_FACTOR = 60 * 60;
public static final int PAGE_PERSIONAL_FACTOR = 60 ;
}
... ...
... ... @@ -13,5 +13,5 @@ public interface ICacheRequest {
* 缓存时间
* @return
*/
int cacheTimeInSecond();
int cacheTimeInMinute();
}
... ...
... ... @@ -38,7 +38,7 @@ public class RecallRequest implements ICacheRequest, IRecallRequest {
RedisKeyBuilder redisKeyBuilder = RedisKeyBuilder.newInstance();
redisKeyBuilder.appendFixed("YOHOSEARCH:").appendFixed("RECALL:");
redisKeyBuilder.appendFixed(strategy.strategtEnum().name()).appendFixed(":");
redisKeyBuilder.appendVar(cacheTimeInSecond()).appendFixed(":");
redisKeyBuilder.appendVar(cacheTimeInMinute()).appendFixed(":");
redisKeyBuilder.appendVar(cacheKey);
return redisKeyBuilder;
}
... ... @@ -49,8 +49,8 @@ public class RecallRequest implements ICacheRequest, IRecallRequest {
}
@Override
public int cacheTimeInSecond() {
return this.strategy.cacheTimeInSecond();
public int cacheTimeInMinute() {
return this.strategy.cacheTimeInMinute();
}
@Override
... ...
... ... @@ -18,11 +18,11 @@ public class SknBaseInfoRequest implements ICacheRequest{
@Override
public RedisKeyBuilder redisKeyBuilder() {
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("SKN_BASE_INFO:").appendVar(cacheTimeInSecond()).appendFixed(":").appendVar(productSkn);
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("SKN_BASE_INFO:").appendVar(cacheTimeInMinute()).appendFixed(":").appendVar(productSkn);
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.SKN_BASE_INFO;
}
... ...
... ... @@ -14,11 +14,11 @@ public class SknReturnInfoResquest implements ICacheRequest {
@Override
public RedisKeyBuilder redisKeyBuilder() {
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("SKN_INFO:").appendVar(cacheTimeInSecond()).appendFixed(":").appendVar(productSkn);
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("SKN_INFO:").appendVar(cacheTimeInMinute()).appendFixed(":").appendVar(productSkn);
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.SKN_RETURN_INFO;
}
... ...
... ... @@ -55,11 +55,11 @@ public class UserRecallRequest implements ICacheRequest {
stringBuilder.append(uid);
stringBuilder.append(udid==null?"": udid);
String value = MD5Util.string2MD5(stringBuilder.toString());
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("USER_RECALL_SKN_LIST:").appendVar(cacheTimeInSecond()).appendFixed(":").appendVar(value);
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("USER_RECALL_SKN_LIST:").appendVar(cacheTimeInMinute()).appendFixed(":").appendVar(value);
}
@Override
public int cacheTimeInSecond() {
public int cacheTimeInMinute() {
return CacheTimeConstants.USER_RECALL_SKN_LIST;
}
... ...