java.lang.Object
com.pixelservices.flash.components.fileserver.AssetCache

public class AssetCache extends Object
AssetCache provides a thread-safe cache for storing file bytes. It is independent of any file system or resource stream details.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the entire cache.
    boolean
    Checks if the cache contains an asset for the given key.
    byte[]
    get(String key)
    Retrieves the cached asset bytes for the given key.
    void
    put(String key, byte[] assetBytes)
    Stores the asset bytes associated with the given key.
    byte[]
    Removes the asset bytes associated with the given key.

    Methods inherited from class java.lang.Object

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

    • AssetCache

      public AssetCache()
  • Method Details

    • put

      public void put(String key, byte[] assetBytes)
      Stores the asset bytes associated with the given key.
      Parameters:
      key - the key (e.g., a route path)
      assetBytes - the bytes to cache
      Throws:
      IllegalArgumentException - if key or assetBytes is null
    • get

      public byte[] get(String key)
      Retrieves the cached asset bytes for the given key.
      Parameters:
      key - the key to look up
      Returns:
      the asset bytes, or null if not found
    • contains

      public boolean contains(String key)
      Checks if the cache contains an asset for the given key.
      Parameters:
      key - the key to check
      Returns:
      true if the cache contains the key; false otherwise
    • remove

      public byte[] remove(String key)
      Removes the asset bytes associated with the given key.
      Parameters:
      key - the key whose entry should be removed
      Returns:
      the removed asset bytes, or null if there was no mapping
    • clear

      public void clear()
      Clears the entire cache.