In hexagonal architecture, domain layer has no dépendency with framework.
Is it possible to use Spring cache in domain layer ?
CodePudding user response:
Caching is application concept, not a business concept: you could write another application for the same business that would not have cache involved. In an hexagonal architecture, caching should go in the adapter layer, not in the domain layer.
CodePudding user response:
Hexagonal architecture isolates the domain logic from the Infrastructure, such as the database, search engine, message queue, mail delivery, and the cache system. The domain is free of any infrastructure and framework boilerplat. Only Infrastructure Layer
must contain the implementation details of Spring Cache. It is achieved via
Cache at the Application layer
Application Service is about use cases. Implementation cache on this level gives you more control of where and when you want to use a cache. You can define Cahce Manager contract at Application layer
and perform implementation details in Infrastructure Layer