IITC.map.Cache()

new Cache()

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

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.

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.

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.

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.

runExpire()

Runs the cache expiration process. This function checks and removes expired cache entries based on the maximum age, item count, and character size limits.

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.

stopExpireInterval()

Stops the interval that checks for cache expiration. This function clears the interval set for running the cache expiration check, effectively stopping automatic cache cleanup.

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.