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?