mercredi 18 mai 2022

Suggest Suitable Approach or Design Pattern for fallbacks in code

I have a below problem statement and seek better advice on Suitable Approach or Design Pattern for fallbacks in code

  • We have 3 database tables and 1 single node redis instance
  • If redis is down for any reason, We want to query directly from individual tables
  • If redis is up and does not have data from database, cache it

Our moto is application should not go down, depending on redis status and work fine.

I can write if / else logic to check redis status in all calls involved in fetching data from individual tables but it violates single responsibility principle and code duplication.

For a cleaner maintainable code, I am seeking better advice from community :)

Kindly let me know if you have trouble understanding my requirement

Aucun commentaire:

Enregistrer un commentaire