Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is caching a repository, domain or application concern?

I am trying to figure out which layer should be responsible for the caching (insert/remove) work in a Domain Driven Design project. The goal is to improve performance of the Web Application by caching any entities that is retrieved from the repository.

My solution is separated as follows:

MyApp.Infrastracture
MyApp.Repositories
MyApp.Domain
MyApp.WebApplication

I feel that since it's only the Web Application that utilises the cache then it should be this layer that the caching logic should go? However this does not feel correct as i want to keep the web app lightweight and focused on serving web pages.

Also caching is not a first class domain concept so does not have a natural fit in the Domain layer.

What to do?

like image 451
Fixer Avatar asked Aug 10 '11 10:08

Fixer


People also ask

Is a cache a repository?

A cache repository is a storage location where Veeam Backup & Replication keeps temporary cached metadata for the data backed up by the file share backup jobs. For more information about cache repository, see NAS Backup Support.

Are repositories part of the domain?

Yes, repository implementations can definitely be a part of your domain model.

Which layer do we use cache?

In computing, a cache is a high-speed data storage layer which stores a subset of data, typically transient in nature, so that future requests for that data are served up faster than is possible by accessing the data's primary storage location.

What is the difference between application layer and domain layer?

Application Layer: Mediates between the Presentation and Domain Layers. Orchestrates business objects to perform specific application tasks. Implements use cases as the application logic. Domain Layer: Includes business objects and the core (domain) business rules.


1 Answers

It is a concern of all of the above.

Caching is one of those cross cutting concerns that each layer needs to handle individually and the application needs to orchestrate.

like image 52
Oded Avatar answered Oct 21 '22 17:10

Oded