class, storage, cache_dir, expiry=<Quantity 10. d>)[source]#

Bases: object

Cache provides a way to download and cache files.

  • downloader (Implementation of DownloaderBase) – Downloader object for downloading remote files.

  • storage (Implementation of StorageProviderBase) – Storage to store metadata about the files.

  • cache_dir (str or pathlib.Path) – Directory where the downloaded files will be stored.

  • expiry (astropy.units.quantity.Quantity or None, optional) – The interval after which the cache is invalidated. If the expiry is None, then the expiry is not checked. Defaults to 10 days.

Methods Summary

download(urls[, namespace, redownload])

Downloads the files from the urls.


Returns the details which is matched by hash if present in cache.

Methods Documentation

download(urls, namespace='', redownload=False)[source]#

Downloads the files from the urls.

The overall flow of this function is:
  1. If redownload: Download, update cache and return file path.

  2. If not redownload: Check cache,
    1. If present in cache:
      • If cache has expired, remove the entry from cache, download and add to cache

      • If cache has not expired, return the path

  • urls (list or str) – A list of urls or a single url.

  • redownload (bool) – Whether to skip cache and redownload.


pathlib.PosixPath – Path to the downloaded file.


Returns the details which is matched by hash if present in cache.


sha_hash (str) – SHA-256 hash of the file.