A
A
Alexander2021-08-12 22:00:07
Software design
Alexander, 2021-08-12 22:00:07

CQRS and cache, how to update the cache?

There is a command that writes data, for example, to postgres and immediately writes the cache to radish. There is a request that reads data from the cache through a decorator and, if it is not in the cache, goes to the database. Would it be correct to put the data back into the cache in the request? Or can update the cache in the team through an event?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2021-08-12
@myks92

The cache needs to be updated on an event

I
Ivan Shumov, 2021-08-12
@inoise

CQRS and cache are not connected in any way. There are different caching strategies and they must be chosen according to the task. You need to understand that there are 2 basic metrics: cache miss and cache hit. If you have a lot of misses, then you need to update the cache in the background. If not, you can do it upon request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question