Package 

Class FileMemoryV2

  • All Implemented Interfaces:
    com.clevertap.android.sdk.inapp.images.memory.Memory

    
    public final class FileMemoryV2
     implements Memory<ByteArray>
                        

    A memory management implementation for all type of files, providing both in-memory and disk-based storage.

    This class utilizes InMemoryLruCache for efficient in-memory caching of files (represented as byte arrays) and DiskMemory for persistent storage of files on disk. It manages the creation and configuration of these storages based on the provided MemoryConfig.

    • Method Summary

      Modifier and Type Method Description
      InMemoryLruCache<Pair<ByteArray, File>> createInMemory() Creates and returns an in-memory LRU cache for storing all type of files as byte arrays.
      DiskMemory createDiskMemory() Creates and returns a disk-based storage mechanism for persisting all type of files.
      Integer inMemorySize() Calculates and returns the size of the in-memory cache in kilobytes.
      Unit freeInMemory() Clears the in-memory cache, releasing all type of held files.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileMemoryV2

        FileMemoryV2(MemoryConfig config, ILogger logger)
        Parameters:
        config - The configuration object specifying parameters for memory management.
        logger - An optional logger for debugging and tracking purposes.
    • Method Detail

      • createDiskMemory

         DiskMemory createDiskMemory()

        Creates and returns a disk-based storage mechanism for persisting all type of files.

        The disk storage is lazily initialized and configured based on the MemoryConfig.

      • inMemorySize

         Integer inMemorySize()

        Calculates and returns the size of the in-memory cache in kilobytes.

        The size is determined based on the MemoryConfig, choosing the larger value between the optimistic size and the minimum in-memory size.

      • freeInMemory

         Unit freeInMemory()

        Clears the in-memory cache, releasing all type of held files.