Class CacheBase
- class ooodev.utils.cache.file_cache.CacheBase(tmp_dir='', lifetime=-1, **kwargs)[source]
Caches files and retrieves cached files. Cached file are in ``ooo_uno_tmpl` subdirectory of LibreOffice tmp dir.
- __init__(tmp_dir='', lifetime=-1, **kwargs)[source]
Constructor
- Parameters:
tmp_dir (Path, str, optional) – Dir name to create in tmp folder.
lifetime (float) – Time in seconds that cache is good for.
kwargs (Any) – Additional keyword arguments. The arguments are used to create a unique instance of the singleton class.
- Return type:
None
Note
The cache root temp folder is the LibreOffice temp folder.
- abstract get(filename)[source]
Fetches file contents from cache if it exist and is not expired
- Parameters:
filename (str) – File to retrieve
- Returns:
File contents if retrieved; Otherwise,
None
- Return type:
Any
- abstract put(filename, content)[source]
Saves file contents into cache
- Parameters:
filename (str) – filename to write.
content (Any) – Contents to write into file.
- Return type:
None
- remove(filename)[source]
Deletes a file from cache if it exist
- Parameters:
filename (Union[str, Path]) – file to delete.
- Return type:
None
- property can_expire: bool
Gets/Sets cache expiration
- Return type:
bool
- property logger: NamedLogger
Gets logger
- Return type:
- property path: Path
Gets cache path
- Return type:
Path
- property path_settings: ThePathSettingsComp
Gets path settings
- Return type:
- property seconds: float
Gets/Sets cache time in seconds
- Return type:
float