https://github.com/isarandi/picklecachefun
Cache function result to disk using pickle
https://github.com/isarandi/picklecachefun
cache caching file-cache persistence pickle python
Last synced: 8 months ago
JSON representation
Cache function result to disk using pickle
- Host: GitHub
- URL: https://github.com/isarandi/picklecachefun
- Owner: isarandi
- License: mit
- Created: 2023-06-05T11:22:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-05T11:58:16.000Z (over 2 years ago)
- Last Synced: 2025-01-16T15:36:00.010Z (10 months ago)
- Topics: cache, caching, file-cache, persistence, pickle, python
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# picklecachefun
Cache the results of function calls to disk, using pickle, similarly to `functools.cache` in the standard library.
## Example usage
Basic use:
```python
import picklecachefun
@picklecachefun.cache('/path/to/filename.pkl')
def some_function(some_arg):
....
return stuff
```
A default cache root can be set too:
```python
picklecachefun.set_cache_root('/path/to/cache')
@picklecachefun.cache('filename.pkl')
...
```
The cache can be invalidated through setting a `min_time`.
In short, set the `min_time` to the timestamp of
when you most recently changed the function definition and need
to invalidate the cache.
```python
@picklecachefun.cache('filename.pkl', min_time="2023-12-04T20:56:48")
...
```