Class TileCache
Index
Constructors
Properties
Methods
Methods
add
Add a key, value combination to the cache, trimming its size if this pushes it over max length.
Parameters
- tileID: OverscaledTileID
lookup key for the item
- data: Tile
tile data
- expiryTimeout: number | void
Returns this
this cache
- tileID: OverscaledTileID
filter
Remove entries that do not pass a filter function. Used for removing stale tiles from the cache.
Parameters
- filterFn: (tile: Tile) => boolean
Determines whether the tile is filtered. If the supplied function returns false, the tile will be filtered out.
Returns void
- filterFn: (tile: Tile) => boolean
get
Get the value attached to a specific key without removing data from the cache. If the key is not found, returns
nullParameters
- tileID: OverscaledTileID
the key to look up
Returns Tile
the tile data, or null if it isn't found
- tileID: OverscaledTileID
getAndRemove
Get the value attached to a specific key and remove data from cache. If the key is not found, returns
nullParameters
- tileID: OverscaledTileID
the key to look up
Returns Tile
the tile data, or null if it isn't found
- tileID: OverscaledTileID
getByKey
Parameters
- key: string
Returns Tile
has
Determine whether the value attached to
keyis presentParameters
- tileID: OverscaledTileID
the key to be looked-up
Returns boolean
whether the cache has this value
- tileID: OverscaledTileID
remove
Remove a key/value combination from the cache.
Parameters
- tileID: OverscaledTileID
the key for the pair to delete
Optionalvalue: { timeout: Timeout; value: Tile }If a value is provided, remove that exact version of the value.
Returns this
this cache
- tileID: OverscaledTileID
reset
Clear the cache
Returns this
this cache
setMaxSize
Change the max size of the cache.
Parameters
- max: number
the max size of the cache
Returns this
this cache
- max: number
number of permitted values