Class OffHeapAssetCache

java.lang.Object
com.atlan.cache.AbstractOffHeapCache<String,T>
com.atlan.cache.OffHeapAssetCache
All Implemented Interfaces:
AtlanCloseable, AutoCloseable

public class OffHeapAssetCache extends AbstractOffHeapCache<String,T>
Generic class through which to cache any assets efficiently, off-heap, to avoid risking extreme memory usage.
  • Constructor Details

    • OffHeapAssetCache

      public OffHeapAssetCache(AtlanClient client, String name)
      Construct new asset cache.
      Parameters:
      client - connectivity to the Atlan tenant
      name - must be unique across the running code
  • Method Details

    • add

      public void add(Asset asset)
      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

      public void extendedWith(OffHeapAssetCache other, boolean closeOriginal)
      Extend this cache with all the entries from the provided cache.
      Parameters:
      closeOriginal - if true, close the provided cache after the extension is complete
      other - other cache with which to extend this one
    • extendedWith

      public void extendedWith(OffHeapAssetCache other, boolean closeOriginal, Predicate<Asset> isValid)
      Extend this cache with all the entries from the provided cache.
      Parameters:
      other - other cache with which to extend this one
      closeOriginal - if true, close the provided cache after the extension is complete
      isValid - 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

      protected byte[] serializeKey(String key)
      Specified by:
      serializeKey in class AbstractOffHeapCache<String,T extends AtlanObject>
    • deserializeKey

      protected String deserializeKey(byte[] bytes)
      Specified by:
      deserializeKey in class AbstractOffHeapCache<String,T extends AtlanObject>
    • serializeValue

      protected byte[] serializeValue(Asset value)
      Specified by:
      serializeValue in class AbstractOffHeapCache<String,T extends AtlanObject>
    • deserializeValue

      protected Asset deserializeValue(byte[] bytes)
      Specified by:
      deserializeValue in class AbstractOffHeapCache<String,T extends AtlanObject>