seismometer.core.decorators.DiskCachedFunction¶
- class seismometer.core.decorators.DiskCachedFunction(cache_name, save_fn, load_fn, return_type=None)¶
- Parameters:
cache_name (str)
save_fn (Callable[[Any], None])
load_fn (Callable[[Path], Any])
return_type (tuple[type])
- __init__(cache_name, save_fn, load_fn, return_type=None)¶
Creates a new decorator that will store data to a cache folder on disk.
Cache can be turned on using the SEISMOMETER_CACHE_ENABLED environment variable.
- Parameters:
cache_name (str) – subdirectory of the cache folder where the new cache will be stored.
save_fn (Callable[[Any], None]) – function that saves the cached type to disk.
load_fun (Callable[[Path], Any]) – function that loads the cached type to disk
return_type (Optional[type | str], optional) – required return type to enable caching, by default None
load_fn (Callable[[Path], Any])
- Return type:
None
Methods
__init__
(cache_name, save_fn, load_fn[, ...])Creates a new decorator that will store data to a cache folder on disk.
clear
()Method to clear the cache directory.
clear_all
()Method to clear all cache directories.
disable
()Method to disable the cache.
enable
()Method to disable the cache.
is_enabled
()Method to check if the cache is enabled.
Attributes
SEISMOMETER_CACHE_DIR
SEISMOMETER_CACHE_ENABLED
cache_dir
Method to return the cache directory.