I'm using python cachetools to cache responses from a remote service. While running the service locally, the following code produces expected results: it calls the external service the first time, and all subsequent requests are served out of the cache.
@staticmethod
@cached(cache=TTLCache(maxsize=10000, ttl=3600))
def func_cache_test(param1, param2):
var1 = call_external_func(param1, param2)
return var1
However, when I run the code on a server(nginx) with multiple cores, it seems to be spinning up a process for each core. Since we have 8 cores on the server, it seems like the program is making up to 8 remote service calls.
I'm not using multi-threading or multi-processing. How do I get all cores(and processes) on the server to share a single cache so I can take full advantage of caching?
Any help is really appreciated.