Metadata-Version: 2.4
Name: funkycache
Version: 1.0.0
Summary: A SQLite-backed function cache that tracks file dependencies
Author-email: Alex Chan <alex@alexwlchan.net>
Maintainer-email: Alex Chan <alex@alexwlchan.net>
License-Expression: MIT
Project-URL: Homepage, https://alexwlchan.net/projects/funkycache/
Project-URL: Changelog, https://alexwlchan.net/projects/funkycache/releases/
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic
Requires-Dist: xxhash
Dynamic: license-file

# funkycache

funkycache is a disk-backed cache for Python functions that tracks file dependencies.
I use it in my static site generator to cache the output of expensive functions.

Example:

```python
from funkycache import FunkyCache

cache = FunkyCache(storage="sqlite")


@cache.register(files=["content/index.md", "templates/base.html"])
def render_index() -> str:
    page = Path("content/index.md").read_text()
    template = Path("templates/base.html").read_text()
    return template.replace("{{ content }}", page)


print(render_index())  # runs the function
print(render_index())  # cache hit, even in a new process

cache.notify_path_change("content/index.md")

print(render_index())  # runs the function again
```

When you register a function with funkycache, you can declare path or static values the function depends on.
If those dependent values change, the function's cache is invalidated, and the next call will rerun the function fresh.

**Note:** funkycache does not watch the filesystem.
It is your responsibility to notify it of changes to dependent files, or they will be noticed when the Python process restarts.

## Installation

Install using pip:

```console
$ pip install funkycache
```

## License

This project is shared under the [MIT license](./LICENSE).
