Releases
v1.2.0
Add the key_transforms parameter to cache.register, which allows you to transform arguments before using them in the cache key, without changing how you call the function or what arguments it receives.
One of the design goals for funkycache is that you should be able to register a function for caching without making any changes to the function itself. Previously, expressing a different cache key from an argument meant creating an “inner function” that received the cache key arguments. For example:
def read_markdown(path: Path) -> str:
return read_markdown_inner(path, path.stat().st_mtime, path.stat().st_size)
@cache.register
def read_markdown_inner(path: Path, mtime: float, size: int) -> str:
return path.read_text()Now you can specify that transformation in cache.register, either with the built-in pathstat transform (which extends the cache key with a file’s modification time and size, or a missing file marker), or with a custom function.
@cache.register(key_transforms={"path": "pathstat"})
def read_markdown(path: Path) -> str: ...
@cache.register(key_transforms={"query": lambda q: q.strip().lower()})
def search_docs(query: str) -> list[str]: ...v1.1.0
To clarify that path dependencies include both files and folders, rename two parameters:
- When calling
cache.register(), usepathsinstead offilesto register path dependencies. - The argument name for
notify_path_changeischanged_pathsinstead ofchanged_files.
The existing parameter names are deprecated and will be removed in a future release.
v1.0.6
Fix a bug in v1.0.5 where closing an unused lazy SQLite cache would cause the database file to be created.
v1.0.5
Change the behaviour of an SQLite-backed cache so the SQLite database is only created when it’s actually used.
This means that if you import a library that has an SQLite-cached function, but you never interact with that function, you don’t get an empty database.
v1.0.4
Tweak how function arguments are encoded as strings to further improve performance.
v1.0.3
Improve the handling of cached generators:
- Do not allow caching generators which send/receive values.
- Allow callers to specify a soft cap for the amount of memory to use when buffering a generator output before skipping the cache and calling the function directly.
v1.0.2
Fix a bug in v1.0.1 where the manager could fail to find already cached values, if the function arguments contained large strings.
v1.0.1
Tweak how function arguments are encoded as strings to improve performance in common cases.
v1.0.0
Initial release.