ptarjan / node-cache

A simple in-memory cache for nodejs
BSD 2-Clause "Simplified" License
1.59k stars 214 forks source link

Singleton on cluster mode #103

Open Wanber opened 6 years ago

Wanber commented 6 years ago

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

TobiasWen commented 6 years ago

I recommend using a redis alternative for that use case.

mike-tobia commented 5 years ago

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.

BCsabaEngine commented 4 years ago

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