Module bus.cache

Class NoOpCache<K,V>

java.lang.Object
org.miaixz.bus.cache.metric.NoOpCache<K,V>
Type Parameters:
K - 键类型
V - 值类型
All Implemented Interfaces:
CacheX<K,V>

public class NoOpCache<K,V> extends Object implements CacheX<K,V>
无缓存实现,用于快速关闭缓存

空操作缓存实现,所有方法都是空操作,不执行任何实际缓存功能。 主要用于需要快速关闭缓存功能的场景,避免修改大量代码。

Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • NoOpCache

      public NoOpCache()
  • Method Details

    • read

      public V read(K key)
      读取缓存值

      空操作,始终返回null

      Specified by:
      read in interface CacheX<K,V>
      Parameters:
      key - 缓存键
      Returns:
      始终返回null
    • write

      public void write(K key, V value, long expire)
      写入缓存值

      空操作,不执行任何操作

      Specified by:
      write in interface CacheX<K,V>
      Parameters:
      key - 缓存键
      value - 缓存值
      expire - 过期时间(毫秒)
    • read

      public Map<K,V> read(Collection<K> keys)
      批量读取缓存值

      空操作,始终返回空Map

      Specified by:
      read in interface CacheX<K,V>
      Parameters:
      keys - 缓存键集合
      Returns:
      始终返回空Map
    • write

      public void write(Map<K,V> keyValueMap, long expire)
      批量写入缓存值

      空操作,不执行任何操作

      Specified by:
      write in interface CacheX<K,V>
      Parameters:
      keyValueMap - 键值映射
      expire - 过期时间(毫秒)
    • remove

      public void remove(K... keys)
      移除缓存

      空操作,不执行任何操作

      Specified by:
      remove in interface CacheX<K,V>
      Parameters:
      keys - 要移除的缓存键
    • clear

      public void clear()
      清空缓存

      空操作,不执行任何操作

      Specified by:
      clear in interface CacheX<K,V>