Skip to main content

tile_cache()

The disk cache for map tiles.

Usage

tile_cache(
    dir=None,
    clear=False,
    max_size=None,
)

Tiles are kept as long as the server’s caching headers allow (a day when they say nothing), so repeated renders of an area do not download them again. The cache starts in BASEMAPPER_CACHE_DIR when set (off disables it), else in the platform cache directory (%LOCALAPPDATA%\basemapper, ~/Library/Caches/basemapper or ~/.cache/basemapper). Set BASEMAPPER_CACHE_DIR in your shell profile or environment to keep a folder for good, or to share one cache with R.

The cache is kept small: expired tiles are deleted, and past its size limit (250 MB, or BASEMAPPER_CACHE_MAX_SIZE in MB) the least recently used tiles go first, in the background as tiles are stored.

Parameters

dir: Optional[str] = None

Move the cache to this directory; False or "" turns it off. None leaves it as it is.

clear: bool = False

Delete every cached tile.

max_size: Optional[float] = None
The cache’s size limit in megabytes; None leaves it as it is.

Returns

Optional[str]
The cache directory, or None when the cache is off.