首页 > 其他分享 >定时300 + 300 随机缓存类

定时300 + 300 随机缓存类

时间:2022-12-28 14:47:10浏览次数:26  
标签:缓存 String 300 randomExpire private int 定时 public

@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

相关文章

  • webpack5 配置多线程和缓存加快构建速度
    webpack5内置了缓存配置在webpack配置对象下,增加:cache:{type:'filesystem',allowCollectingMemory:true}webpack5可以通过引入 threa......
  • spring-boot 整合redis作为数据缓存
     添加依赖<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-redis</artifactId></dependency>......
  • 定时问题
    ThedifferencebetweenscheduleAtFixedRateandscheduleWithFixedDelayinJAVARecently,duetotheprojectneeds,IhavetousemultithreadtechnologyinJAV......
  • vue首页缓存
    vue.config.js添加chainWebpack:config=>{        config.plugins.delete('prefetch');//取消预加载    config.plugins.delete('preload......
  • winfrom 窗体定时关闭
    publicForm1(){InitializeComponent();tmr=newSystem.Windows.Forms.Timer();tmr.Tick+=delegate{......
  • 定时自动备份【新增飞塔防火墙】
    新增飞塔防火墙支持命令行导出配置随即新增两个脚本做测试(testforti,user1.passwd),同理之前的脚本DEVICENAME=(`cat/home/Network_Config_Backup/user1.passwd|awk'{pr......
  • odoo 集群频繁更新静态资源包,并失效缓存
    频繁的更新会影响服务的性能发生该事件的核心代码deflookup(self,method,*args,**kwargs):d,key0,counter=self.lru(args[0])key=key0......
  • CF234C 1300
    题意最后要形成形如前面从1k范围内全为负数,从k+1n范围内全为正数,没有0的存在,那此时最少应该改变几个值。解析ca[i]统计前面到i一共有多少个>=0的,cb[i]代表后面到i一共......
  • CF189A 1300
    题意解析3个物品的完全背包。f[i][j]代表选到第i件物品此时恰凑成长度j的数量的最大值代码#include<bits/stdc++.h>usingnamespacestd;typedeflonglongll;con......
  • Linux设置每晚定时备份Oracle数据表
    先新建目录该路径:/home/oracle/backup该名称:DATA_PATHshell脚本exportORACLE_BASE=/home/oracle/appexportORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome......