Skip to content

cache

This module takes care of managing caching configuration.

get_cache_dir()

Get the cache directory used by stocktracer.

Users can customize this directory on all systems using STOCKTRACER_CACHE_DIR environment variable. By default, the cache directory is the user cache directory under the stocktracer application.

This result is immediately set to a constant stocktracer.cache.CACHE_DIR as to avoid repeated calls.

Returns:

Name Type Description
Path Path

path to the cache directory

Source code in src/stocktracer/cache.py
@beartype
def get_cache_dir() -> Path:
    """Get the cache directory used by stocktracer.

    Users can customize this directory on all systems using `STOCKTRACER_CACHE_DIR`
    environment variable. By default, the cache directory is the user cache directory
    under the stocktracer application.

    This result is immediately set to a constant `stocktracer.cache.CACHE_DIR` as to avoid
    repeated calls.

    Returns:
        Path: path to the cache directory
    """
    default_cache_dir = user_cache_dir("stocktracer")
    cache_dir = Path(os.environ.get("STOCKTRACER_CACHE_DIR", default_cache_dir))
    return cache_dir

Last update: July 3, 2023