Interface NonceCache

All Known Implementing Classes:
MemoryNonceCache

public interface NonceCache
Nonce缓存接口

用于存储已使用的nonce,防止重放攻击

实现类: 1. MemoryNonceCache:框架内置的内存实现,适用于单节点部署(默认) 2. 分布式实现:多副本部署由业务方实现本接口(如基于 Redis 的原子操作)并注册为 Bean, 框架的 @ConditionalOnMissingBean 内存实现会自动让位;框架不内置任何分布式缓存模块。

Author:
Kerbores(kerbores@riemann.tech)
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    setIfAbsent(String nonce, String value, long expireSeconds)
    如果nonce不存在则设置
  • Method Details

    • setIfAbsent

      boolean setIfAbsent(String nonce, String value, long expireSeconds)
      如果nonce不存在则设置

      此操作必须是原子性的,以保证并发安全

      Parameters:
      nonce - nonce值
      value - 存储的值
      expireSeconds - 过期时间(秒)
      Returns:
      是否设置成功(false表示已存在)