new geo.tileCache(options)
This class implements a simple cache for tile objects. Each tile is stored in cache object keyed by a configurable hashing function. Another array keeps track of last access times for each tile to purge old tiles once the maximum cache size is reached.
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
A configuration object for the cache.
|
Members
-
length
-
Get the current cache size. Read only.
Properties:
Name Type Description length
number The current cache size.
-
size
-
Get/set the maximum cache size.
Properties:
Name Type Description size
number The maximum cache size.
Methods
-
add(tile, removeFunc, noPurge)
-
Add a tile to the cache.
Name Type Description tile
geo.tile The tile to add.
removeFunc
function If specified and tiles must be purged from the cache, call this function on each tile before purging.
noPurge
boolean if true, don't purge tiles.
-
clear(){this}
-
Remove all tiles from the cache.
Returns:
Type Description this -
get(hash, noMove){geo.tile|null}
-
Get a tile from the cache if it exists, otherwise return
null
. This method also moves the tile to the front of the access queue.Name Type Description hash
string | geo.tile The tile or the tile hash value.
noMove
boolean optional If truthy, don't move the tile to the front of the access queue.
Returns:
Type Description geo.tile | null -
purge(removeFunc)
-
Purge tiles from the cache if it is full.
Name Type Description removeFunc
function If specified and tiles must be purged from the cache, call this function on each tile before purging.
-
remove(tile){boolean}
-
Remove a tile from the cache.
Name Type Description tile
string | geo.tile The tile or its hash.
Returns:
Type Description boolean true
if a tile was removed.