node-cache icon indicating copy to clipboard operation
node-cache copied to clipboard

Singleton on cluster mode

Open Wanber opened this issue 7 years ago • 3 comments

I have an api gateway running in cluster mode (4), using this lib to cache requests, is there any way to share an instance of lib between the 4 processes?

captura de tela 2018-06-05 as 09 06 23

Wanber avatar Jun 05 '18 12:06 Wanber

I recommend using a redis alternative for that use case.

TobiasWen avatar Jun 06 '18 14:06 TobiasWen

I was actually thinking about this earlier - on a high level you could open a file on the master and have a queue of operations manage the cache, writing to the disk (persistence?) in tandem to updating the workers when change happens. It's naive but all the threads can share the same cache that way.

mike-tobia avatar Oct 26 '18 02:10 mike-tobia

Singleton cannot solve problem. Interprocess communication can solve with outer solution like memcached.

BCsabaEngine avatar Jul 04 '20 06:07 BCsabaEngine