Package noaa.coastwatch.io.tile
Class LRUTileCache
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<TileCacheKey,
,TilingScheme.Tile> TileCache
public class LRUTileCache
extends LinkedHashMap<TileCacheKey,TilingScheme.Tile>
implements TileCache
The
LRUTileCache
is a tile cache that uses a
least-recently-used rule to eliminate unused tiles.- Since:
- 3.3.1
- Author:
- Peter Hollemans
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
int
Gets the total cache size in bytes.int
Gets the total cache size limit in bytes.static void
Tests this class.put
(TileCacheKey key, TilingScheme.Tile value) protected boolean
void
setCacheSizeLimit
(int bytes) Sets the total cache size limit in bytes.Methods inherited from class java.util.LinkedHashMap
containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, size
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, size, values
-
Constructor Details
-
LRUTileCache
public LRUTileCache()Creates a new empty cache with maximum 16 Mb data.
-
-
Method Details
-
setCacheSizeLimit
public void setCacheSizeLimit(int bytes) Description copied from interface:TileCache
Sets the total cache size limit in bytes.- Specified by:
setCacheSizeLimit
in interfaceTileCache
- Parameters:
bytes
- the number of bytes allowed in the cache. The cache must delete tiles if adding a tile would go over this limit.
-
getCacheSizeLimit
public int getCacheSizeLimit()Description copied from interface:TileCache
Gets the total cache size limit in bytes.- Specified by:
getCacheSizeLimit
in interfaceTileCache
- Returns:
- the number of bytes allowed in the cache. The cache must delete tiles if adding a tile would go over this limit.
-
getCacheSize
public int getCacheSize()Description copied from interface:TileCache
Gets the total cache size in bytes.- Specified by:
getCacheSize
in interfaceTileCache
- Returns:
- the number of bytes currently in the cache.
-
removeEldestEntry
- Overrides:
removeEldestEntry
in classLinkedHashMap<TileCacheKey,
TilingScheme.Tile>
-
remove
- Specified by:
remove
in interfaceMap<TileCacheKey,
TilingScheme.Tile> - Overrides:
remove
in classHashMap<TileCacheKey,
TilingScheme.Tile>
-
put
- Specified by:
put
in interfaceMap<TileCacheKey,
TilingScheme.Tile> - Overrides:
put
in classHashMap<TileCacheKey,
TilingScheme.Tile>
-
clear
public void clear()- Specified by:
clear
in interfaceMap<TileCacheKey,
TilingScheme.Tile> - Overrides:
clear
in classLinkedHashMap<TileCacheKey,
TilingScheme.Tile>
-
main
Tests this class.- Parameters:
argv
- the array of command line parameters.- Throws:
Exception
-