Class AssetCache
java.lang.Object
com.pixelservices.flash.components.fileserver.AssetCache
AssetCache provides a thread-safe cache for storing file bytes.
It is independent of any file system or resource stream details.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the entire cache.boolean
Checks if the cache contains an asset for the given key.byte[]
Retrieves the cached asset bytes for the given key.void
Stores the asset bytes associated with the given key.byte[]
Removes the asset bytes associated with the given key.
-
Constructor Details
-
AssetCache
public AssetCache()
-
-
Method Details
-
put
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
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
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
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.
-