2

I have a Node application with a number of workers that serve dynamic pages. Each worker needs to have access to a central object, which contains methods to find and cache information from a 3rd party API. This object will be on the master process so that the workers can easily communicate with it.

I would like to be able to access the cache and API methods easily, and get the response in a callback on the worker process. For example: if I wanted to get a user from the API (or cache if cached), I would call something like getUser('userID', callback) where callback is a function that would be called with the users details, or an error if one occurred.

Is there any simple ways that I can do this? or have I designed it badly? Is there a better way to share a single instance of something between multiple workers?

user2248702
  • 2,741
  • 7
  • 41
  • 69
  • redis is probably better suited to acting as your cache. – josh3736 Mar 23 '16 at 04:01
  • I would still need a way of requesting the cached data from a worker, as I cannot have multiple instances of the object that interfaces with the third party API. – user2248702 Mar 23 '16 at 04:09

0 Answers0