Interface Cache<K,V>

Type Parameters:
K - the key type
V - the value type
All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
AbstractCache, CaffeineCache, DistributedCache, Ehcache, LocalCache, OffHeapCache

public interface Cache<K,V> extends Closeable
Since:
0.8
Author:
Haiyang Li
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
    static final long
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.landawn.abacus.util.ContinuableFuture<Boolean>
    Async contains key.
    com.landawn.abacus.util.ContinuableFuture<com.landawn.abacus.util.u.Optional<V>>
     
    com.landawn.abacus.util.ContinuableFuture<V>
     
    com.landawn.abacus.util.ContinuableFuture<Boolean>
    asyncPut(K k, V v)
     
    com.landawn.abacus.util.ContinuableFuture<Boolean>
    asyncPut(K k, V v, long liveTime, long maxIdleTime)
     
    com.landawn.abacus.util.ContinuableFuture<Void>
     
    void
    Remove all cached entities from cache pool.
    void
    release the resource token by this cache.
    boolean
     
    com.landawn.abacus.util.u.Optional<V>
    get(K k)
     
    com.landawn.abacus.util.Properties<String,Object>
    Gets the properties.
    <T> T
    getProperty(String propName)
    Gets the property.
    gett(K k)
    Gets the t.
    boolean
     
     
    boolean
    put(K k, V v)
     
    boolean
    put(K k, V v, long liveTime, long maxIdleTime)
     
    void
    remove(K k)
     
    <T> T
    Returns value of the property which is to be removed, null if it doesn't exist.
    <T> T
    setProperty(String propName, Object propValue)
    Returns the old value associated with the property by the propName, null if it doesn't exist.
    int
     
  • Field Details

  • Method Details

    • get

      com.landawn.abacus.util.u.Optional<V> get(K k)
      Parameters:
      k -
      Returns:
      V
    • gett

      V gett(K k)
      Gets the t.
      Parameters:
      k -
      Returns:
      V
    • put

      boolean put(K k, V v)
      Parameters:
      k -
      v -
      Returns:
      true, if successful
    • put

      boolean put(K k, V v, long liveTime, long maxIdleTime)
      Parameters:
      k -
      v -
      liveTime - unit is milliseconds
      maxIdleTime - unit is milliseconds
      Returns:
      true, if successful
    • remove

      void remove(K k)
      Parameters:
      k -
    • containsKey

      boolean containsKey(K k)
      Parameters:
      k -
      Returns:
      boolean
    • asyncGet

      com.landawn.abacus.util.ContinuableFuture<com.landawn.abacus.util.u.Optional<V>> asyncGet(K k)
      Parameters:
      k -
      Returns:
    • asyncGett

      com.landawn.abacus.util.ContinuableFuture<V> asyncGett(K k)
      Parameters:
      k -
      Returns:
    • asyncPut

      com.landawn.abacus.util.ContinuableFuture<Boolean> asyncPut(K k, V v)
      Parameters:
      k -
      v -
      Returns:
    • asyncPut

      com.landawn.abacus.util.ContinuableFuture<Boolean> asyncPut(K k, V v, long liveTime, long maxIdleTime)
      Parameters:
      k -
      v -
      liveTime -
      maxIdleTime -
      Returns:
    • asyncRemove

      com.landawn.abacus.util.ContinuableFuture<Void> asyncRemove(K k)
      Parameters:
      k -
      Returns:
    • asyncContainsKey

      com.landawn.abacus.util.ContinuableFuture<Boolean> asyncContainsKey(K k)
      Async contains key.
      Parameters:
      k -
      Returns:
    • keySet

      Set<K> keySet()
      Returns:
      Set
    • size

      int size()
      Returns:
    • clear

      void clear()
      Remove all cached entities from cache pool.
    • close

      void close()
      release the resource token by this cache.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isClosed

      boolean isClosed()
      Returns:
      true, if is closed
    • getProperties

      com.landawn.abacus.util.Properties<String,Object> getProperties()
      Gets the properties.
      Returns:
    • getProperty

      <T> T getProperty(String propName)
      Gets the property.
      Type Parameters:
      T -
      Parameters:
      propName -
      Returns:
    • setProperty

      <T> T setProperty(String propName, Object propValue)
      Returns the old value associated with the property by the propName, null if it doesn't exist.
      Type Parameters:
      T -
      Parameters:
      propName -
      propValue -
      Returns:
    • removeProperty

      <T> T removeProperty(String propName)
      Returns value of the property which is to be removed, null if it doesn't exist.
      Type Parameters:
      T -
      Parameters:
      propName -
      Returns: