Package com.atlan.cache
Class OffHeapAssetCache
- All Implemented Interfaces:
AtlanCloseable
,AutoCloseable
Generic class through which to cache any assets efficiently, off-heap, to avoid risking extreme
memory usage.
-
Constructor Summary
ConstructorDescriptionOffHeapAssetCache
(AtlanClient client, String name) Construct new asset cache. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an asset into the cache.protected String
deserializeKey
(byte[] bytes) protected Asset
deserializeValue
(byte[] bytes) void
extendedWith
(OffHeapAssetCache other, boolean closeOriginal) Extend this cache with all the entries from the provided cache.void
extendedWith
(OffHeapAssetCache other, boolean closeOriginal, Predicate<Asset> isValid) Extend this cache with all the entries from the provided cache.protected byte[]
serializeKey
(String key) protected byte[]
serializeValue
(Asset value) Methods inherited from class com.atlan.cache.AbstractOffHeapCache
close, containsKey, entrySet, get, getName, getSize, isEmpty, isNotClosed, isNotEmpty, put, putAll, size, values
-
Constructor Details
-
OffHeapAssetCache
Construct new asset cache.- Parameters:
client
- connectivity to the Atlan tenantname
- must be unique across the running code
-
-
Method Details
-
add
Add an asset into the cache. Note: the object MUST have a real (not a placeholder) UUID to be cached.- Parameters:
asset
- to add to the cache
-
extendedWith
Extend this cache with all the entries from the provided cache.- Parameters:
closeOriginal
- if true, close the provided cache after the extension is completeother
- other cache with which to extend this one
-
extendedWith
Extend this cache with all the entries from the provided cache.- Parameters:
other
- other cache with which to extend this onecloseOriginal
- if true, close the provided cache after the extension is completeisValid
- boolean method that takes a single asset as an argument, and only when evaluated to true for an asset in the other cache will that entry from the other cache be included in this one
-
serializeKey
- Specified by:
serializeKey
in classAbstractOffHeapCache<String,
T extends AtlanObject>
-
deserializeKey
- Specified by:
deserializeKey
in classAbstractOffHeapCache<String,
T extends AtlanObject>
-
serializeValue
- Specified by:
serializeValue
in classAbstractOffHeapCache<String,
T extends AtlanObject>
-
deserializeValue
- Specified by:
deserializeValue
in classAbstractOffHeapCache<String,
T extends AtlanObject>
-