public class LRUTileCache extends java.util.LinkedHashMap<TileCacheKey,TilingScheme.Tile> implements TileCache
LRUTileCache
is a tile cache that uses a
least-recently-used rule to eliminate unused tiles.Constructor and Description |
---|
LRUTileCache()
Creates a new empty cache with maximum 16 Mb data.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
int |
getCacheSize()
Gets the total cache size in bytes.
|
int |
getCacheSizeLimit()
Gets the total cache size limit in bytes.
|
static void |
main(java.lang.String[] argv)
Tests this class.
|
TilingScheme.Tile |
put(TileCacheKey key,
TilingScheme.Tile value) |
TilingScheme.Tile |
remove(java.lang.Object key) |
protected boolean |
removeEldestEntry(java.util.Map.Entry<TileCacheKey,TilingScheme.Tile> eldest) |
void |
setCacheSizeLimit(int bytes)
Sets the total cache size limit in bytes.
|
containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, size
public LRUTileCache()
public void setCacheSizeLimit(int bytes)
TileCache
setCacheSizeLimit
in interface TileCache
bytes
- the number of bytes allowed in the cache. The cache
must delete tiles if adding a tile would go over this limit.public int getCacheSizeLimit()
TileCache
getCacheSizeLimit
in interface TileCache
public int getCacheSize()
TileCache
getCacheSize
in interface TileCache
protected boolean removeEldestEntry(java.util.Map.Entry<TileCacheKey,TilingScheme.Tile> eldest)
removeEldestEntry
in class java.util.LinkedHashMap<TileCacheKey,TilingScheme.Tile>
public TilingScheme.Tile remove(java.lang.Object key)
remove
in interface java.util.Map<TileCacheKey,TilingScheme.Tile>
remove
in class java.util.HashMap<TileCacheKey,TilingScheme.Tile>
public TilingScheme.Tile put(TileCacheKey key, TilingScheme.Tile value)
put
in interface java.util.Map<TileCacheKey,TilingScheme.Tile>
put
in class java.util.HashMap<TileCacheKey,TilingScheme.Tile>
public void clear()
clear
in interface java.util.Map<TileCacheKey,TilingScheme.Tile>
clear
in class java.util.LinkedHashMap<TileCacheKey,TilingScheme.Tile>
public static void main(java.lang.String[] argv) throws java.lang.Exception
argv
- the array of command line parameters.java.lang.Exception