Interface Cache

All Known Implementing Classes:
DefaultCache

public interface Cache
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear deletes all items stored in the cache.
    void
    Delete removes the specific key from the cache.
    boolean
    get(String key)
    Get returns the result for the given key.
    boolean
    set(String key, boolean value, Object... extra)
    Set puts key and value into cache.
  • Method Details

    • set

      boolean set(String key, boolean value, Object... extra)
      Set puts key and value into cache. The first extra parameter should be a java.time.LocalDateTime object denoting the expected survival time. If survival time equals 0 or less, the key will always be valid.
      Parameters:
      key - the key to store
      value - the value to store
      extra - additional parameters (e.g., expiration time)
      Returns:
      true if successful, false otherwise
    • get

      boolean get(String key)
      Get returns the result for the given key. If there's no such key in the cache, Optional.empty() will be returned.
      Parameters:
      key - the key to retrieve
      Returns:
      an Optional containing the boolean value if present, otherwise Optional.empty()
    • delete

      void delete(String key)
      Delete removes the specific key from the cache. If the key doesn't exist, it returns false.
      Parameters:
      key - the key to delete
    • clear

      void clear()
      Clear deletes all items stored in the cache.