Disk Tile Cache
Persistent disk cache for map tiles.
Stores up to 50MB of tiles in the app's cache directory, one file per tile, with the bytes exactly as the tile server sent them. Tiles persist across app restarts, reducing network usage on subsequent launches. When the size limit is reached, the least recently used tiles are deleted.
Tiles older than 7 days count as expired: get ignores them, so they are downloaded again, but they stay on disk as a fallback for when the download fails (e.g. offline), see the allowStale parameter of get.
Tiles are stored under a namespace (e.g. the tile source), so tiles of different sources never replace each other. All instances in a process share the size accounting per directory.
The cache stays usable after clear, and a failing cache only results in cache misses.
Parameters
Context used to locate the app's cache directory
Prefix for the cache keys, e.g. the name of the tile source
Functions
Returns the cached tile, decoded with RGB_565, or null if it is missing.
Stores a decoded tile as PNG. Prefer the put overload with the original bytes, which avoids re-encoding.
Stores the tile bytes as sent by the tile server.