Hello!
In my Post Login
Action, I have code that generates and caches a specific value that can be reused across multiple requests. This works well—when a new login request comes in, I can retrieve the cached value instead of regenerating it.
However, I’m now trying to use the same caching logic in a Pre User Registration
Action. While Auth0’s documentation says caching is supported in this action, it appears that cached values are only retained for the duration of a single request. When a new registration request comes in, the cached value is no longer available. I am using a new and different cache key to avoid any collision issues as well, but the value still gets lost across multiple requests.
Is there anyone that can answer why this occurs? Is there any way to cache values across multiple requests like the Post Login
action does?
exports.onExecutePreUserRegistration = async (event, api) => {
console.log('*** Test Cache ***');
console.log(`Test Key At Start value: ${api.cache.get('test')?.value}`);
api.cache.set('test', 'iamasecretvalue', { ttl: 9999999999 });
console.log(`Test Key After Being Set value: ${api.cache.get('test')?.value}`);
console.log('************************')
console.log("************** End of Pre-Registration Action ***************");
};
When this action gets hit multiple times across multiple requests, the cache does not contain the value for the test
key. It is only present in the cache once set for the single request.