You can virtually place your Cache access operations (read/write) wherever you have data, but in order to design modular and maintainable software it’s a good idea to centralize these operations into a separate layer to encapsulate and prevent ripple effect when changing the underlying provider (imagine that you start using Memcached, however your design should be good enough to allow a migration to somewhere like AppFabric Caching Service). Now the question is: where does exactly in my design fit the Cache layer?
The worst answer I can think of it’s replying with only one possibility. As a software Designer/Architect you should consider many scenarios and chose the best. Avoid facing your design decisions with a golden hammer / silver bullet. A common poor answer is placing the Cache layer between your Business and Data Layers. Another common answer is placing it between the Data Layer and the underlying data store.
The best thing to do is checking all the possibilities and assesses them according to your needs. In my experience I prefer caching in UI Components, UI Process Components, Data Access Components or in Service Agents because those scenarios offer performance improvements.
Another factor that can influence your decision is if you want caching fine-grained or coarse-grained data. I mean, you can opt between caching a plain query result or an UI-Entity collection ready to be consumed by the front-end.
Cheers,
Javier Andrés Cáceres Alvis
Microsoft Most Valuable Professional – MVP Intel Black Belt Software Developer
Publicado por Where do I place my Cache Layer? « MSExpertos en 15 agosto, 2012 at 13:08
[...] Where do I place my Cache Layer? [...]
Publicado por How do I design my Cache layer? « Javier Andres Caceres Alvis – C# para Windows Phone 7 en 7 septiembre, 2012 at 11:28
[...] I discussed about the best place to put the Cache layer from an architectural point of view. The main ideas of that discussion are summarized as [...]
Publicado por How do I design my Cache layer? « MSExpertos en 25 septiembre, 2012 at 12:15
[...] Previously I discussed about some places to put the Cache layer from an architectural point of view. The main ideas of that discussion are summarized as [...]
Publicado por How do I design my Cache layer? « MVPs de LATAM en 5 octubre, 2012 at 16:32
[...] I discussed about some places to put the Cache layer from an architectural point of view. The main ideas of that discussion are summarized as [...]