You've already forked FrameTour-BE
价格缓存清理
This commit is contained in:
@@ -8,6 +8,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
@@ -48,14 +49,15 @@ public class PriceRepository {
|
||||
if (redisTemplate.hasKey(String.format(PRICE_ID_CACHE, id))) {
|
||||
PriceConfigEntity priceConfig = getPriceConfig(id);
|
||||
if (priceConfig != null) {
|
||||
clearPriceCache(priceConfig.getScenicId(), priceConfig.getType(), priceConfig.getGoodsIds());
|
||||
clearPriceScenicCache(priceConfig.getScenicId());
|
||||
}
|
||||
}
|
||||
redisTemplate.delete(String.format(PRICE_ID_CACHE, id));
|
||||
}
|
||||
|
||||
public void clearPriceCache(Long scenicId, Integer type, String goodsId) {
|
||||
String cacheKey = String.format(PRICE_SCENIC_TYPE_GOODS_CACHE, scenicId, type, goodsId);
|
||||
redisTemplate.delete(cacheKey);
|
||||
public void clearPriceScenicCache(Long scenicId) {
|
||||
String cacheKey = String.format("price:s%s:*", scenicId);
|
||||
Set<String> keys = redisTemplate.keys(cacheKey);
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user