On this page

Class TileCache

Index

Constructors

  • Parameters

    • max: number

      number of permitted values

    • onRemove: (element: Tile) => void

      callback called with items when they expire

    Returns TileCache

Properties

data: { [key: string]: { timeout: Timeout; value: Tile }[] }
max: number
onRemove: (element: Tile) => void
order: string[]

Methods

  • Add a key, value combination to the cache, trimming its size if this pushes it over max length.

    Parameters

    Returns this

    this cache

  • 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

  • Get the value attached to a specific key without removing data from the cache. If the key is not found, returns null

    Parameters

    Returns Tile

    the tile data, or null if it isn't found

  • Get the value attached to a specific key and remove data from cache. If the key is not found, returns null

    Parameters

    Returns Tile

    the tile data, or null if it isn't found

  • Parameters

    • key: string

    Returns Tile

  • Determine whether the value attached to key is present

    Parameters

    Returns boolean

    whether the cache has this value

  • 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

  • Clear the cache

    Returns this

    this cache

  • Change the max size of the cache.

    Parameters

    • max: number

      the max size of the cache

    Returns this

    this cache

Was this helpful?
SDK JS
Reference
TileCache