Package com.landawn.abacus.cache
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 typeV- the value type
- All Implemented Interfaces:
Cache<K,,V> Closeable,AutoCloseable
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
-
Field Summary
Fields inherited from interface com.landawn.abacus.cache.Cache
DEFAULT_LIVE_TIME, DEFAULT_MAX_IDLE_TIME -
Constructor Summary
ConstructorsConstructorDescriptionOffHeapCache(int sizeMB) The memory with the specified size of MB will be allocated at application start up.OffHeapCache(int sizeMB, long evictDelay) The memory with the specified size of MB will be allocated at application start up.OffHeapCache(int sizeMB, long evictDelay, long defaultLiveTime, long defaultMaxIdleTime) The memory with the specified size of MB will be allocated at application start up. -
Method Summary
Methods inherited from class com.landawn.abacus.cache.AbstractCache
asyncContainsKey, asyncGet, asyncGett, asyncPut, asyncPut, asyncRemove, get, getProperties, getProperty, put, removeProperty, setProperty
-
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 millisecondsdefaultLiveTime- unit is millisecondsdefaultMaxIdleTime- unit is milliseconds
-
-
Method Details
-
gett
Gets the t.- Parameters:
k-- Returns:
-
put
- Parameters:
k-v-liveTime-maxIdleTime-- Returns:
- true, if successful
-
remove
- Parameters:
k-
-
containsKey
- Parameters:
k-- Returns:
- true, if successful
-
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
-