Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 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 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-05T11:58:16.000Z (over 1 year ago)
- Last Synced: 2023-08-29T11:28:38.219Z (over 1 year 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")
...
```