DataCache()

new DataCache()

DataCache constructor. Manages a cache for map data tiles. The cache has a maximum age and size limit, and these limits can vary for mobile and desktop environments.

Methods

static window.DataCache#get(qk) → {object|undefined}

Retrieves the data for a given key from the cache.

Parameters:
Name Type Description
qk string

The key of the data to retrieve.

Returns:
object | undefined -

The cached data if it exists, otherwise undefined.

static window.DataCache#getTime(qk) → {number}

Retrieves the timestamp for the given key from the cache.

Parameters:
Name Type Description
qk string

The key of the data to check.

Returns:
number -

The timestamp of the data if it exists, otherwise 0.

static window.DataCache#isFresh(qk) → {boolean|undefined}

Checks if the data for the given key is fresh.

Parameters:
Name Type Description
qk string

The key of the data to check.

Returns:
boolean | undefined -

True if the data is fresh, false if it's stale, undefined if data doesn't exist.

static window.DataCache#remove(qk)

Removes a specific entry from the cache based on its key.

Parameters:
Name Type Description
qk string

The key of the data to remove from the cache.

static window.DataCache#startExpireInterval(period)

Starts the interval to periodically run the cache expiration.

Parameters:
Name Type Description
period number

The period in seconds between each expiration run.

static window.DataCache#store(qk, data)

Stores data in the cache. If an entry for the given key already exists, it's removed before the new data is stored. The data is stored along with its timestamp and expiration time.

Parameters:
Name Type Description
qk string

The key under which to store the data.

data object

The data to be stored in the cache.