Context: I am working on an application which loads a cache on startup - periodically refreshed. However it turns out that this cache is something which is very general and can be used by other applications as well. Currently as a work around other applications are using rest commands on this application to fetch data from the cache - but I think this is a wrong pattern. Alternatively, the cache should be moved into its own service which is responsible for maintaining and refreshing the cache.

My question is once the cache server is up and running - whose responsibility should it be to refresh the cache? Here are two approaches I have -

  1. Services interact via messages; The caching service can publish a message to all clients, asking the clients to update their local copy of the cache as it is now stale.

  2. The clients poll the caching service periodically to update their cache.

  • Is there a reason you don’t just use Redis? Dec 24, 2022 at 23:02
  • How will using Redis solve this problem? Dec 24, 2022 at 23:05
  • 1
    It does not solve the problem. This was about why you use a homegrown solution instead of an existing one. And what you have now is really not jusr a cache anymore Dec 25, 2022 at 0:29
  • Well, technically speaking a caching server can use Redis as the cache. My question is something between - should 5 applications be loading the same cache on their own - or should be a single application which loads the cache and others can fetch data from it. Dec 25, 2022 at 1:29
  • 1
    The answer here depends on your requirements; which one(s) of CAP are you prepared to give up? Dec 25, 2022 at 6:00


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.