reprospect.tools.cacher module
- class reprospect.tools.cacher.Cacher(directory: str | Path)View on GitHub
Bases:
ABCCache results.
The cacher stores the files as follows:
~/.<cache_dir>/ ├── <hash>/ │ ├── file_A │ ├── file_B │ └── ... └── cache.db
Available hashes are stored in a SQLITE database (
cache.db) that also stores the timestamp at which the entry was populated.Inspired by
ccache, see also https://ccache.dev/manual/4.12.1.html#_how_ccache_works.- class Entry(cached: 'bool', digest: 'str', timestamp: 'datetime.datetime', directory: 'pathlib.Path')View on GitHub
Bases:
object
- __enter__() SelfView on GitHub
Connect to the database.
- __exit__(*args, **kwargs) NoneView on GitHub
- __init__(directory: str | Path) NoneView on GitHub
- Parameters:
directory – Where the cacher stores all files.
- create_db(file: Path) ConnectionView on GitHub
Create the SQLITE database.
- get(**kwargs) EntryView on GitHub
Serve cached entry on cache hit, populate on cache miss.
- hash(**kwargs) blake3View on GitHub
This method is intended to be overridden in a child class with the specifics of your case.
- abstractmethod populate(directory: Path, **kwargs) NoneView on GitHub