Skip to main content

Releases

v1.2.0 · 00743a6

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 · b57f330

To clarify that path dependencies include both files and folders, rename two parameters:

The existing parameter names are deprecated and will be removed in a future release.

v1.0.6 · 13dbfce

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 · b0506ed

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 · 19f9783

Tweak how function arguments are encoded as strings to further improve performance.

v1.0.3 · d519037

Improve the handling of cached generators:

v1.0.2 · 0f346d2

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 · 80aad94

Tweak how function arguments are encoded as strings to improve performance in common cases.

v1.0.0 · 93b0316

Initial release.