cache functions output with auto refresh everytime you call it
Project description
functions cache
This library is inspired by requests-cache https://github.com/reclosedev/requests-cache and the whole engines code has been copied and modified from there.
this library provide a decorator that can be used to decorate your functions to be cached.
The main feature that diffentiate this library is that it will auto refresh the cache in a background thread so your cache will be kept fresh.
Sample code
from functions_cache import cache_it
import datetime
@cache_it
def fab_cached(n):
if n < 2:
return n
else:
return fab_cached(n-2)+fab_cached(n-1)
if __name__ == "__main__":
t1 = datetime.datetime.now()
print(fab_cached(100))
t2 = datetime.datetime.now()
print(t2-t1)
t3 = datetime.datetime.now()
print(fab_cached(100))
t4 = datetime.datetime.now()
print(t4-t3)
and the output
354224848179261915075
0:00:03.366472
354224848179261915075
0:00:00.014370
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
functions-cache-0.1.0.tar.gz
(14.5 kB
view hashes)
Built Distribution
Close
Hashes for functions_cache-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a19b50157e3b9b96af5882ef57515c86b4e828e126bfa14ce03423db6af2a643 |
|
MD5 | 6fa4f80a6b3afffa137d74969882beef |
|
BLAKE2b-256 | 7e729760fe5ccba5d461998ff41160e69311a5942ae9b9a475292dc3124bd88b |