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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()intGets the total cache size in bytes.intGets the total cache size limit in bytes.static voidTests this class.put(TileCacheKey key, TilingScheme.Tile value) protected booleanvoidsetCacheSizeLimit(int bytes) Sets the total cache size limit in bytes.Methods inherited from class java.util.LinkedHashMap
containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, sizeMethods inherited from class java.util.AbstractMap
equals, hashCode, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:TileCacheSets the total cache size limit in bytes.- Specified by:
setCacheSizeLimitin 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:TileCacheGets the total cache size limit in bytes.- Specified by:
getCacheSizeLimitin 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:TileCacheGets the total cache size in bytes.- Specified by:
getCacheSizein interfaceTileCache- Returns:
- the number of bytes currently in the cache.
-
removeEldestEntry
- Overrides:
removeEldestEntryin classLinkedHashMap<TileCacheKey,TilingScheme.Tile>
-
remove
- Specified by:
removein interfaceMap<TileCacheKey,TilingScheme.Tile> - Overrides:
removein classHashMap<TileCacheKey,TilingScheme.Tile>
-
put
- Specified by:
putin interfaceMap<TileCacheKey,TilingScheme.Tile> - Overrides:
putin classHashMap<TileCacheKey,TilingScheme.Tile>
-
clear
public void clear()- Specified by:
clearin interfaceMap<TileCacheKey,TilingScheme.Tile> - Overrides:
clearin classLinkedHashMap<TileCacheKey,TilingScheme.Tile>
-
main
Tests this class.- Parameters:
argv- the array of command line parameters.- Throws:
Exception
-