tileCache

geo. tileCache

new tileCache(optionsopt)

Description:
  • 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.

Source:
Parameters:
Name Type Attributes Description
options object <optional>

A configuration object for the cache.

Properties
Name Type Attributes Default Description
size number <optional>
64

The maximum number of tiles to store.

Members

length

Description:
  • Get the current cache size. Read only.

Source:
Properties:
Name Type Description
length number

The current cache size.

Get the current cache size. Read only.

size

Description:
  • Get/set the maximum cache size.

Source:
Properties:
Name Type Description
size number

The maximum cache size.

Get/set the maximum cache size.

Methods

add(tile, removeFunc, noPurge)

Description:
  • Add a tile to the cache.

Source:
Parameters:
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}

Description:
  • Remove all tiles from the cache.

Source:
Returns:
Type
this

get(hash, noMoveopt) → {geo.tile|null}

Description:
  • 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.

Source:
Parameters:
Name Type Attributes 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
geo.tile | null

purge(removeFunc)

Description:
  • Purge tiles from the cache if it is full.

Source:
Parameters:
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}

Description:
  • Remove a tile from the cache.

Source:
Parameters:
Name Type Description
tile string | geo.tile

The tile or its hash.

Returns:

true if a tile was removed.

Type
boolean