Module bus.cache

Annotation Interface Cached


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface Cached
缓存注解

用于标记方法使用缓存功能。当方法被调用时,会先从缓存中查找结果, 如果缓存中没有,则执行方法并将结果存入缓存。

Since:
Java 17+
Author:
Kimi Liu
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    使用SpEL表达式
    int
    过期时间
    指定每个键的前缀
    指定使用的缓存实现
  • Element Details

    • value

      String value
      指定使用的缓存实现

      默认使用在CacheAspect中配置的第一个caches

      Returns:
      缓存实现名称
      Default:
      ""
    • prefix

      String prefix
      指定每个键的前缀

      如果方法没有参数,prefix将作为该方法使用的常量键

      Returns:
      键前缀
      Default:
      ""
    • condition

      String condition
      使用SpEL表达式

      当这个SpEL表达式为true时,该方法会使用缓存

      Returns:
      SpEL条件表达式
      Default:
      ""
    • expire

      int expire
      过期时间

      时间单位:毫秒

      Returns:
      过期时间(毫秒)
      Default:
      0