lair.config.get_cache_dir#

lair.config.get_cache_dir()[source]#

Resolve the cache directory.

The environment variable LAIR_CACHE_DIR is read each time this is called, not when lair is imported, so setting it after import lair works. The folder is not made here: the code that caches makes it the first time it writes there, so import lair works where the home directory is read-only.

Returns:

Path – $LAIR_CACHE_DIR, or .cache/lair in the home directory when the variable is unset or empty.

Return type:

Path

See also

get_data_dir

The folder of a data archive, which has no default.

lair.records.Cacher

Writes the cache files.

Examples

>>> import os
>>> from lair.config import get_cache_dir
>>> os.environ["LAIR_CACHE_DIR"] = "/scratch/lair_cache"
>>> get_cache_dir().as_posix()
'/scratch/lair_cache'
>>> del os.environ["LAIR_CACHE_DIR"]
>>> get_cache_dir().parts[-2:]
('.cache', 'lair')