Authored by hugufei

fix

... ... @@ -5,8 +5,11 @@ import com.yoho.core.redis.cluster.operations.nosync.YHRedisTemplate;
import com.yoho.core.redis.cluster.operations.nosync.YHValueOperations;
import com.yoho.search.common.cache.model.CacheObject;
import com.yoho.search.common.utils.RedisCacheUtils;
import com.yoho.search.core.redis.components.YohoNoSyncRedisComponent;
import com.yoho.search.core.redis.components.YohoSearchRedisComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
... ... @@ -21,15 +24,13 @@ public class YohoRedis implements CacheInterface {
private static final Logger logger = LoggerFactory.getLogger(YohoRedis.class);
@Redis("yohoNoSyncRedis")
public YHValueOperations yhNoSyncValueOperations;
@Redis("yohoNoSyncRedis")
public YHRedisTemplate yhNoSyncRedisTemplate;
@Autowired
private YohoNoSyncRedisComponent yohoNoSyncRedisComponent;
@Override
public CacheObject get(String key) {
try {
return RedisCacheUtils.get(yhNoSyncValueOperations, key, CacheObject.class);
return RedisCacheUtils.get(yohoNoSyncRedisComponent.getValueOperations(), key, CacheObject.class);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return null;
... ... @@ -39,7 +40,7 @@ public class YohoRedis implements CacheInterface {
@Override
public void addOrUpdate(String key, CacheObject value, int expiredTimeInMinute) {
try {
RedisCacheUtils.add(yhNoSyncValueOperations, key, value, expiredTimeInMinute);
RedisCacheUtils.add(yohoNoSyncRedisComponent.getValueOperations(), key, value, expiredTimeInMinute);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
... ... @@ -49,7 +50,7 @@ public class YohoRedis implements CacheInterface {
@Override
public void delete(String key) {
try {
RedisCacheUtils.delete(yhNoSyncRedisTemplate, key);
RedisCacheUtils.delete(yohoNoSyncRedisComponent.getRedisTemplate(), key);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
... ... @@ -58,7 +59,7 @@ public class YohoRedis implements CacheInterface {
@Override
public boolean exist(String key) {
try {
return RedisCacheUtils.exist(yhNoSyncRedisTemplate, key);
return RedisCacheUtils.exist(yohoNoSyncRedisComponent.getRedisTemplate(), key);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
... ...