@Component public class ProductCacheKeyService { private static String PRODUCT_BASE_INFO = "product_info_%s"; //商品信息BIG KEY private Random random = new Random(); @Value("${search.categoryProduct.config.cache.baseExpire:300}") private int baseExpire;//过期 秒 @Value("${search.categoryProduct.config.cache.randomExpire:300}") public int randomExpire;//随机过期 秒 public static String getProductCacheKey(String spuId) { return String.format(PRODUCT_BASE_INFO, spuId); } public int getExpire() { return baseExpire + random.nextInt(randomExpire); } }
标签:缓存,String,300,randomExpire,private,int,定时,public From: https://www.cnblogs.com/niun/p/17010091.html