- Cachier is a Python package providing persistent, stale-free memoization decorators for Python functions, supporting local (pickle), cross-machine (MongoDB), and in-memory caching backends.
- Always refer to the main decorator as
@cachier, and note that it can be configured via parameters such asstale_after,backend,mongetter,cache_dir,pickle_reload,separate_files,wait_for_calc_timeout, andallow_none. - Arguments to cached functions must be hashable; custom hash functions can be provided via the
hash_funcparameter for unhashable arguments. - The default backend is pickle-based, storing cache files in
~/.cachier/unless otherwise specified. MongoDB and memory backends are also supported. - Cachier is thread-safe and supports per-function cache clearing via the
clear_cache()method on decorated functions. - Global configuration is possible via
set_default_paramsandenable_caching/disable_cachingfunctions. - When reviewing code, ensure new features or bugfixes maintain compatibility with Python 3.9+, preserve thread safety, and follow the numpy docstring conventions for documentation.
- Tests are located in the
tests/directory and should be run withpytest. MongoDB-related tests require either a mocked or live MongoDB instance. - When discussing or generating code, prefer concise, readable, and well-documented Python code, and follow the established conventions in the codebase and README.
- For documentation, follow numpy docstring conventions and validate changes to
README.rstwithpython setup.py checkdocs.