I've created a python package that does some expensive computation and uses lru_cache
in order to save the result so the user don't have to wait too long for the result being calculated.
import cachetools.func
@cachetools.func.ttl_cache(ttl=60*60)
def main_function():
# some expensive computations
return result
The code works pretty well when I call directly the function from a file or from the Python Shell, my issue is that when calling this package from my Django project, somehow it doesn't look up the already cached results.
In my __init__.py
file I'm calling main_function
and then I try to call it again from my Django project but it does not return the cached response, instead it runs the function again.
The package that I've created has a complex cache system, it works nice so I think this may be a problem with Django, that somehow I need to manage the caches from my Django project, any suggestions on how can I solve this?
question from:
https://stackoverflow.com/questions/65871366/backend-cache-not-shared-with-django 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…