Module bus.cache

Class GuavaCache<K,V>

java.lang.Object
org.miaixz.bus.cache.metric.GuavaCache<K,V>
All Implemented Interfaces:
CacheX<K,V>

public class GuavaCache<K,V> extends Object implements CacheX<K,V>
Guava 缓存支持
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Summary

    Constructors
    Constructor
    Description
    GuavaCache(long size, long expire)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    清空缓存信息
    read(Collection<K> keys)
    从缓存中获得一组对象信息
    read(K key)
    从缓存中获得对象
    void
    remove(K... keys)
    从缓存中移除对象
    void
    write(Map<K,V> keyValueMap, long expire)
    将对象加入到缓存,使用指定失效时长
    void
    write(K key, V value, long expire)
    将对象加入到缓存,使用指定失效时长

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.miaixz.bus.cache.CacheX

    containsKey
  • Constructor Details

    • GuavaCache

      public GuavaCache(long size, long expire)
  • Method Details

    • read

      public V read(K key)
      Description copied from interface: CacheX
      从缓存中获得对象
      Specified by:
      read in interface CacheX<K,V>
      Parameters:
      key - 键
      Returns:
      键对应的对象
    • read

      public Map<K,V> read(Collection<K> keys)
      Description copied from interface: CacheX
      从缓存中获得一组对象信息
      Specified by:
      read in interface CacheX<K,V>
      Parameters:
      keys - 多个键
      Returns:
      值对象
    • write

      public void write(K key, V value, long expire)
      Description copied from interface: CacheX
      将对象加入到缓存,使用指定失效时长
      Specified by:
      write in interface CacheX<K,V>
      Parameters:
      key - 键
      value - 缓存的对象
      expire - 失效时长,单位毫秒
    • write

      public void write(Map<K,V> keyValueMap, long expire)
      Description copied from interface: CacheX
      将对象加入到缓存,使用指定失效时长
      Specified by:
      write in interface CacheX<K,V>
      Parameters:
      keyValueMap - 缓存的对象
      expire - 失效时长,单位毫秒
      See Also:
    • remove

      public void remove(K... keys)
      Description copied from interface: CacheX
      从缓存中移除对象
      Specified by:
      remove in interface CacheX<K,V>
      Parameters:
      keys - 键
    • clear

      public void clear()
      Description copied from interface: CacheX
      清空缓存信息
      Specified by:
      clear in interface CacheX<K,V>