Hi,
I have a few Netlify functions.
I know server-less functions are meant to be stateless, so I use a node module called
Memory-cache to save some information which will be shared between these functions.
Say there are 2 functions:
saveSubscription():
const cache=require(“memory-cache”)
cache.put(“subscriptions”, subs)
showSubscriptions():
const cache=require(“memory-cache”)
cache.get(“subscriptions”)
From the Function log under Netlify’s Functions tab, I can see that
when calling saveSubscription(sub), it does save the subscription to the memory cache, and if I save another one, I can see the both inside the cache; if I save the same subscription, I fetch subscriptions from cache and can detect the duplication.
but when I call showSubscriptions(), from the log panel, I can also see that the subscriptions are always empty.
This makes me thinking that different functions do not share cache momery?
I thought all my functions will be running on a same server.
How could I share the stored subscriptions between functions?