Tile Cache
Two-level cache for map tiles: in-memory LRU cache backed by persistent disk cache.
Memory cache holds up to 1/8 of available heap memory for fast access. The tile caches of all maps with a disk cache share one memory cache, with the tiles of each namespace kept apart. So a map shown again, e.g. in a tab or a list, draws its tiles from the first frame on, instead of waiting for them to be read from disk. put also writes the tile to the disk cache, so call it from a background thread. Disk cache stores up to 50MB of tiles to reduce network requests across app restarts.
A tile older than the disk cache's maximum age is only returned by getStale, as a fallback when a fresh download failed. It is then marked as stale (see isStale) until a fresh tile is put.
Parameters
Context for the disk cache, or null for a memory-only cache of its own
Disk cache namespace, e.g. the tile source, so tiles of different sources are stored separately
Constructors
Functions
Returns the tile from memory (which may be stale, see isStale), or a fresh tile from disk.
Returns the tile even if its disk entry has expired, for use when downloading a fresh tile failed (e.g. offline). An expired tile is promoted to memory and marked as stale.
Returns true if the tile in the memory cache is an expired one from getStale, which should be replaced by a fresh download.
Puts the tile into the memory cache and the disk cache.