...
|
...
|
@@ -8,6 +8,7 @@ import com.yoho.core.redis.cluster.operations.nosync.YHZSetOperations; |
|
|
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
|
|
|
import com.yohoufo.common.cache.CacheHelper;
|
|
|
import com.yohoufo.common.cache.CacheKeyEnum;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.user.model.UserAuthorizeInfo;
|
|
|
import com.yohoufo.dal.user.model.UserFavorite;
|
|
|
import com.yohoufo.dal.user.model.UserFavoriteSku;
|
...
|
...
|
@@ -61,6 +62,11 @@ public class CacheService { |
|
|
return RedisKeyBuilder.newInstance().appendFixed(CacheKeyEnum.USER_SKU_FAVORITE_ZSET_KEY.getCacheKey()).appendVar(uid);
|
|
|
}
|
|
|
|
|
|
/////// 相关的key构造
|
|
|
public static RedisKeyBuilder getSkuFavoriteFlagRedisKeyBuilder(Integer uid, Integer storageId){
|
|
|
return RedisKeyBuilder.newInstance().appendFixed(CacheKeyEnum.USER_SKU_FAVORITE_FLAG_KEY.getCacheKey()).appendVarWithMH(uid).appendVar(storageId);
|
|
|
}
|
|
|
|
|
|
/**************************************************************************
|
|
|
* 商品收藏相关
|
|
|
*************************************************************************/
|
...
|
...
|
@@ -428,6 +434,18 @@ public class CacheService { |
|
|
return set;
|
|
|
}
|
|
|
|
|
|
|
|
|
public boolean setNxKey(Integer userId, Integer storageId) {
|
|
|
Boolean aBoolean = yhValueOperations.setIfAbsent(getSkuFavoriteFlagRedisKeyBuilder(userId, storageId), String.valueOf(DateUtil.getCurrentTimeSecond()));
|
|
|
if (aBoolean) {
|
|
|
yhRedisTemplate.longExpire(getSkuFavoriteFlagRedisKeyBuilder(userId, storageId),
|
|
|
CacheKeyEnum.USER_SKU_FAVORITE_FLAG_KEY.getDefaultExpireTime(),
|
|
|
CacheKeyEnum.USER_SKU_FAVORITE_FLAG_KEY.getTimeUnit());
|
|
|
}
|
|
|
|
|
|
return aBoolean;
|
|
|
}
|
|
|
|
|
|
private String getSkuFacoriteValue(Integer storageId, BigDecimal price) {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.append(storageId).append(":").append(price);
|
...
|
...
|
|