This question stems from this other question I had asked about too many interfaces, QCRS and Mediatr library (request/response)
Mediatr: reducing number of DI'ed objects
I have created bunch of commands and queries and I have bunch of behaviors and one of them being is a Cache behaviour that for every query, cache is checked for the value before the query is actually executed against the db. So far this is working great, but the delima comes in when I have an UpdateSomethingCommand, once I update the underlying object in the db, I would like to refresh the cache with what was successfully saved to the db.
My question is specifically when to actually update the cache:
- In the UpdateSomethingCommandHandler (this might be breaking the SOLID principal)
- Call another command in UpdateSomethingCommandHanlder that is specifically designed to update caches (not sure this is a good design principal)
- Introduce another behavior that is specifically designed for updating caches (not sure how to go about this yet)
- Is there a better solution?