Ok, I build application using three layers for manipulating business logic.
1) First layer solve transport tasks. The layer send requests, get responses and handle network errors. Transport layer call remote API methods and prepares data for using inside application.
2) Second layer is a Service. Service is a class (or group of functions) for manipulating specific data from API to organize it in accordance with business requirements. For example ProductService fetch list of products then denormalize each of them to object and make sorted collection.
3) And third layer is a Controller. This layer is a classic layer from MVC pattern. It refers to the service for data and pass it to View layer.
As a result we get the scheme of interaction:
Controller => Service => Transport
It is obvious that this scheme requires storing the result to caching service. Therefore it is necessary to add a fourth layer - Cache.
So in what place in this scheme should be located Cache layer and which of three layers above should to control it (saying fetch data from cache or get from API, invalidate cache, etc)?
My question is conceptual issue and its not require indication specific technologies, however I want to get an answer in the context of PHP and Symfony 2/3 framework.
Aucun commentaire:
Enregistrer un commentaire