nearform / fast-jwt

Fast JSON Web Token implementation
https://nearform.github.io/fast-jwt/
Other
334 stars 28 forks source link

Shared memory caching with cluster mode #421

Open asvyazhin opened 5 months ago

asvyazhin commented 5 months ago

Thank you for this awesome library. I really like the idea about LRU caching! I would like to know is it possible to have a single (shared) memory cache when nodejs app is running in cluster mode – each available core runs a separate app instance?

simoneb commented 5 months ago

I don't think this scenario was ever considered, and clearly it wouldn't be straightforward to implement either, because with Node.js clustering you would effectively have process isolation, meaning that passing of state would require an explicit approach, making it considerably inconvenient. In this specific case, my feeling is that the cost of doing anything like this would largely outweigh any benefit you may get from a shared cache.

We're open to ideas and proposals though, maybe you have something specific in mind that I haven't considered.