Class AccessLimitedStampManager

java.lang.Object
cn.herodotus.engine.cache.jetcache.stamp.AbstractStampManager<String,Long>
cn.herodotus.engine.web.service.stamp.AccessLimitedStampManager
All Implemented Interfaces:
StampManager<String,Long>, org.springframework.beans.factory.InitializingBean

public class AccessLimitedStampManager extends AbstractStampManager<String,Long>

Description: 防刷签章管理器

这里使用Long类型作为值的存储类型,是为了解决该Cache 同时可以存储Duration相关的数据

Author:
: gengwei.zheng
Date:
: 2021/8/25 21:43
  • Constructor Details

    • AccessLimitedStampManager

      public AccessLimitedStampManager(SecureProperties secureProperties)
  • Method Details

    • getSecureProperties

      public SecureProperties getSecureProperties()
    • nextStamp

      public Long nextStamp(String key)
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Throws:
      Exception
    • calculateRemainingTime

      public Duration calculateRemainingTime(Duration configuredDuration, String expireKey)
      计算剩余过期时间

      每次create或者put,缓存的过期时间都会被覆盖。(注意:Jetcache put 方法的参数名:expireAfterWrite)。 因为Jetcache没有Redis的incr之类的方法,那么每次放入Times值,都会更新过期时间,实际操作下来是变相的延长了过期时间。

      Parameters:
      configuredDuration - 注解上配置的、且可以正常解析的Duration值
      expireKey - 时间标记存储Key值。
      Returns:
      还剩余的过期时间 Duration