A scientific toolkit that will inspire you and your team to work with more collaboration than ever before.
It works almost like LRU Cache but allows you:
- Use the same cache in different processes;
- Use the same cache at the different moments of time;
- Easily share your local runtime results with your teammates!
Using memcached as a backend allows you to cache really large things.
Using pip:
pip install keepthis
From source:
# 1. clone this repo
git clone https://github.com/puhoshville/keepthis.git
# 2. cd to repository's root directory
cd keepthis
# 3. install
pip install -e .
I recommend you to use docker image for your first-time interactions with the library:
docker run -d --rm -p 11211:11211 memcached
More information about docker image
! Before using KeepThis please make sure that you have memcached instance to store cache.
-
Import and initialize instance
from keepthis import KeepThis keep = KeepThis('localhost', 11211) # connect to local memcached instance
-
Define a function with keepthis decorator
@keep.this def get_fibonacci(num): if num == 0: return 1 if num == 1: return 1 return get_fibonacci(num-1) + get_fibonacci(num-2)
-
Done! All computations will be stored in memcached and will be reused if needed.
You can find out usage examples of KeepThis in examples/
and notebooks/