Class MemoryCacheAdapter

  • All Implemented Interfaces:
    MemoryCache

    public class MemoryCacheAdapter
    extends java.lang.Object
    implements MemoryCache
    A simple class that ignores all puts and returns null for all gets.
    • Constructor Detail

      • MemoryCacheAdapter

        public MemoryCacheAdapter()
    • Method Detail

      • getCurrentSize

        public long getCurrentSize()
        Description copied from interface: MemoryCache
        Returns the sum of the sizes of all the contents of the cache in bytes.
        Specified by:
        getCurrentSize in interface MemoryCache
      • getMaxSize

        public long getMaxSize()
        Description copied from interface: MemoryCache
        Returns the current maximum size in bytes of the cache.
        Specified by:
        getMaxSize in interface MemoryCache
      • setSizeMultiplier

        public void setSizeMultiplier​(float multiplier)
        Description copied from interface: MemoryCache
        Adjust the maximum size of the cache by multiplying the original size of the cache by the given multiplier.

        If the size multiplier causes the size of the cache to be decreased, items will be evicted until the cache is smaller than the new size.

        Specified by:
        setSizeMultiplier in interface MemoryCache
        Parameters:
        multiplier - A size multiplier >= 0.
      • remove

        @Nullable
        public Resource<?> remove​(@NonNull
                                  Key key)
        Description copied from interface: MemoryCache
        Removes the value for the given key and returns it if present or null otherwise.
        Specified by:
        remove in interface MemoryCache
        Parameters:
        key - The key.
      • put

        @Nullable
        public Resource<?> put​(@NonNull
                               Key key,
                               @Nullable
                               Resource<?> resource)
        Description copied from interface: MemoryCache
        Add bitmap to the cache with the given key.
        Specified by:
        put in interface MemoryCache
        Parameters:
        key - The key to retrieve the bitmap.
        resource - The EngineResource to store.
        Returns:
        The old value of key (null if key is not in map).
      • clearMemory

        public void clearMemory()
        Description copied from interface: MemoryCache
        Evict all items from the memory cache.
        Specified by:
        clearMemory in interface MemoryCache
      • trimMemory

        public void trimMemory​(int level)
        Description copied from interface: MemoryCache
        Trim the memory cache to the appropriate level. Typically called on the callback onTrimMemory.
        Specified by:
        trimMemory in interface MemoryCache
        Parameters:
        level - This integer represents a trim level as specified in ComponentCallbacks2.