Package org.geotools.gce.imagemosaic
Class GuavaGranuleImageCache
Object
GuavaGranuleImageCache
- All Implemented Interfaces:
GranuleImageCache
Default
GranuleImageCache: a single-JVM, heap-backed pool over a Guava Cache. Thread-safe.-
Nested Class Summary
Nested classes/interfaces inherited from interface GranuleImageCache
GranuleImageCache.MissingRasterException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget(ImageCacheKey key) Returns the cached image for the key, ornullon a miss; never loads.longLargest decoded granule eligible for caching, in bytes (a read parameter can override it).longMaximum size of the pool, in bytes.getOrLoad(ImageCacheKey key, Callable<BufferedImage> loader) Returns the cached image for the key, loading it once atomically if absent.voidDrops all cached granule images.voidinvalidateGranule(URL granuleUrl) Drops every cached read of the given granule, whatever the mosaic, image index or band selection.voidinvalidateMosaic(String mosaicId) Drops every entry owned by the given mosaic, called when its reader is disposed to free heap at once.booleanWhether caching is on: a non-positive max size means the pool is present but denies caching.voidreconfigure(long maximumSizeBytes, long defaultThresholdBytes) Applies new sizing while keeping this instance's identity, so readers holding it throughHints.GRANULE_IMAGE_CACHEsee the change with no rebuild on their side.longsize()Number of granule images currently held.
-
Constructor Details
-
GuavaGranuleImageCache
public GuavaGranuleImageCache(long maximumSizeBytes, long defaultThresholdBytes)
-
-
Method Details
-
reconfigure
public void reconfigure(long maximumSizeBytes, long defaultThresholdBytes) Description copied from interface:GranuleImageCacheApplies new sizing while keeping this instance's identity, so readers holding it throughHints.GRANULE_IMAGE_CACHEsee the change with no rebuild on their side. A change in total size may drop the current entries and free their heap at once; the threshold is applied in place.- Specified by:
reconfigurein interfaceGranuleImageCache
-
isEnabled
public boolean isEnabled()Description copied from interface:GranuleImageCacheWhether caching is on: a non-positive max size means the pool is present but denies caching.- Specified by:
isEnabledin interfaceGranuleImageCache
-
size
public long size()Description copied from interface:GranuleImageCacheNumber of granule images currently held.- Specified by:
sizein interfaceGranuleImageCache
-
invalidateAll
public void invalidateAll()Description copied from interface:GranuleImageCacheDrops all cached granule images.- Specified by:
invalidateAllin interfaceGranuleImageCache
-
invalidateGranule
Description copied from interface:GranuleImageCacheDrops every cached read of the given granule, whatever the mosaic, image index or band selection.- Specified by:
invalidateGranulein interfaceGranuleImageCache
-
invalidateMosaic
Description copied from interface:GranuleImageCacheDrops every entry owned by the given mosaic, called when its reader is disposed to free heap at once.- Specified by:
invalidateMosaicin interfaceGranuleImageCache
-
getMaximumSizeBytes
public long getMaximumSizeBytes()Description copied from interface:GranuleImageCacheMaximum size of the pool, in bytes.- Specified by:
getMaximumSizeBytesin interfaceGranuleImageCache
-
getDefaultThresholdBytes
public long getDefaultThresholdBytes()Description copied from interface:GranuleImageCacheLargest decoded granule eligible for caching, in bytes (a read parameter can override it).- Specified by:
getDefaultThresholdBytesin interfaceGranuleImageCache
-
get
Description copied from interface:GranuleImageCacheReturns the cached image for the key, ornullon a miss; never loads.- Specified by:
getin interfaceGranuleImageCache
-
getOrLoad
Description copied from interface:GranuleImageCacheReturns the cached image for the key, loading it once atomically if absent. Returnsnullif the loader signals nothing was read by throwingGranuleImageCache.MissingRasterException; any other loader failure propagates.- Specified by:
getOrLoadin interfaceGranuleImageCache- Throws:
Exception
-