Class OffHeapCache<K,V>

java.lang.Object
com.landawn.abacus.cache.AbstractCache<K,V>
com.landawn.abacus.cache.OffHeapCache<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
Cache<K,V>, Closeable, AutoCloseable

public class OffHeapCache<K,V> extends AbstractCache<K,V>
It's not designed for tiny objects(length of bytes < 128 after serialization). Since it's off heap cache, modifying the objects from cache won't impact the objects in cache.
Since:
0.8
Author:
haiyang li
  • Constructor Details

    • OffHeapCache

      public OffHeapCache(int sizeMB)
      The memory with the specified size of MB will be allocated at application start up.
      Parameters:
      sizeMB -
    • OffHeapCache

      public OffHeapCache(int sizeMB, long evictDelay)
      The memory with the specified size of MB will be allocated at application start up.
      Parameters:
      sizeMB -
      evictDelay - unit is milliseconds
    • OffHeapCache

      public OffHeapCache(int sizeMB, long evictDelay, long defaultLiveTime, long defaultMaxIdleTime)
      The memory with the specified size of MB will be allocated at application start up.
      Parameters:
      sizeMB -
      evictDelay - unit is milliseconds
      defaultLiveTime - unit is milliseconds
      defaultMaxIdleTime - unit is milliseconds
  • Method Details

    • gett

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

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

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

      public boolean containsKey(K k)
      Parameters:
      k -
      Returns:
      true, if successful
    • keySet

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

      public int size()
      Returns:
    • clear

      public void clear()
      Clear.
    • close

      public void close()
      Close.
    • isClosed

      public boolean isClosed()
      Checks if is closed.
      Returns:
      true, if is closed