Cache#
- class sunpy.data.data_manager.Cache(downloader, storage, cache_dir, expiry=<Quantity 10. d>)[source]#
Bases:
object
Cache provides a way to download and cache files.
- Parameters:
downloader (Implementation of
DownloaderBase
) – Downloader object for downloading remote files.storage (Implementation of
StorageProviderBase
) – Storage to store metadata about the files.cache_dir (
str
orpathlib.Path
) – Directory where the downloaded files will be stored.expiry (
astropy.units.quantity.Quantity
orNone
, optional) – The interval after which the cache is invalidated. If the expiry isNone
, then the expiry is not checked. Defaults to 10 days.
Methods Summary
download
(urls[, namespace, redownload])Downloads the files from the urls.
get_by_hash
(sha_hash)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:
If
redownload
: Download, update cache and return file path.- If not
redownload
: Check cache, - 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
- If not
- Parameters:
- Returns:
pathlib.PosixPath
– Path to the downloaded file.