Module bus.cache

Interface CacheX<K,V>

All Known Implementing Classes:
GuavaCache, MemcachedCache, MemoryCache, NoOpCache, RedisCache, RedisClusterCache

public interface CacheX<K,V>
缓存接口
Since:
Java 17+
Author:
Kimi Liu
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    清空缓存信息
    default boolean
    是否存在key,如果对应key的value值已过期,也返回false
    read(Collection<K> keys)
    从缓存中获得一组对象信息
    read(K key)
    从缓存中获得对象
    void
    remove(K... keys)
    从缓存中移除对象
    void
    write(Map<K,V> map, long expire)
    将对象加入到缓存,使用指定失效时长
    void
    write(K key, V value, long expire)
    将对象加入到缓存,使用指定失效时长
  • Method Details

    • read

      V read(K key)
      从缓存中获得对象
      Parameters:
      key - 键
      Returns:
      键对应的对象
    • read

      Map<K,V> read(Collection<K> keys)
      从缓存中获得一组对象信息
      Parameters:
      keys - 多个键
      Returns:
      值对象
    • write

      void write(K key, V value, long expire)
      将对象加入到缓存,使用指定失效时长
      Parameters:
      key - 键
      value - 缓存的对象
      expire - 失效时长,单位毫秒
    • write

      void write(Map<K,V> map, long expire)
      将对象加入到缓存,使用指定失效时长
      Parameters:
      map - 缓存的对象
      expire - 失效时长,单位毫秒
      See Also:
    • containsKey

      default boolean containsKey(K key)
      是否存在key,如果对应key的value值已过期,也返回false
      Parameters:
      key - 缓存key
      Returns:
      true:存在key,并且value没过期;false:key不存在或者已过期
    • remove

      void remove(K... keys)
      从缓存中移除对象
      Parameters:
      keys - 键
    • clear

      void clear()
      清空缓存信息