Interface Cache

All Known Implementing Classes:
LocalCacheImpl, RedisCacheImpl

public interface Cache
缓存服务
Author:
Toint
  • Method Details

    • put

      void put(String key, String value, Duration timeout)
      设置缓存
      Parameters:
      key - 缓存键, 不能为空
      value - 缓存值
      timeout - 缓存时间, 不能为空
    • putIfAbsent

      boolean putIfAbsent(String key, String value, Duration timeout)
      设置缓存如果不存在
      Parameters:
      key - 缓存键, 不能为空
      value - 缓存值
      timeout - 缓存时间, 不能为空
      Returns:
      true=设置成功, false=不成功
    • get

      String get(String key)
      获取缓存
      Parameters:
      key - 缓存键
      Returns:
      缓存值
    • multiGet

      List<String> multiGet(Collection<String> keys)
      获取缓存
      Parameters:
      keys - 缓存键
      Returns:
      缓存值集合, 如果对应位置的key不存在, 则用null占位
    • containsKey

      boolean containsKey(String key)
      缓存是否存在
      Parameters:
      key - 缓存键, 不能为空
      Returns:
      true=存在, false=不存在
    • delete

      void delete(String key)
      删除缓存
      Parameters:
      key - 缓存键, 不能为空