Class DiskPersistedCache<K,V>
- Type Parameters:
K- key typeV- value type
This cache is composed of a smaller in-memory LRU cache (level 1) and a disk-based storage layer for persistence (level 2). The level 1 cache 1 cache is item-limited, while the eclipse storage layer is not limited. However, values in the level 2 cache will be replaced with lazy references after 30 seconds. In this sense, the level 2 cache is only used for persistence and loading persisted values into the level 1 cache.
When entries are added to the cache, the entry is added to both the level 1 level 2 caches. If an entry already exists in either cache, it will be replaced.
When keys are requested from the cache, the level 1 cache is first checked. If the level 1 cache does not contain an entry for the key, the level 2 cache is checked. If the key is not present in the level 2 cache, a null value is returned. If the key exists, the value will be lazily loaded from the EclipseStorage layer, placed into the level 1 cache, and returned to the caller.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> DiskPersistedCache.Builder<K, V> DiskPersistedCache BuildergetOrDefault(K key, V defaultValue) name()longlongvoidvoidreinit()remove all cached entities from both the level 1 and level 2 cachesvoidbooleanrunning()voidvoidvoidshutdown()
-
Method Details
-
at
DiskPersistedCache Builder- Type Parameters:
K- cache keyV- cache value- Parameters:
cacheDir- location of the disk persisted cache- Returns:
- a DiskPersistedCache builder
- Throws:
IOException- if an i/o issue related tocacheDiris encountered
-
get
-
getOrDefault
-
put
-
remove
-
numL1Keys
public long numL1Keys() -
numL2Keys
public long numL2Keys() -
reinit
public void reinit()remove all cached entities from both the level 1 and level 2 caches -
name
-
running
public boolean running() -
showL1Db
-
showL2Db
-
shutdown
public void shutdown()
-