Search code examples
cachingaopappfabricpostsharp

Is it wise to use AppFabric + Postsharp for server side caching


One of my friends wants to use AppFabric caching on server side (WCF services).

But to reduce similar functionality across services code, he wants to cache data "automatically" using AOP Postsharp + AppFabric cache.

Is it wise to use automatically caching in such style on server side?


Solution

  • The real question is: Does it make sense for your project? It is acceptable to automatically cache output from a method using aspects. It's less code you have to write and manage. Caching is a cross-cutting concern which is where AOP comes in. PostSharp is the leading AOP framework in the .NET world.

    So, if you have code that does caching and you've tested it and it's proven then put it into an aspect and use it, then reuse it. It doesn't matter if it's local memory or app-fabric. If it makes sense then do it.

    It's the same as you manually writing the code everytime, except you only need to write it once and PostSharp "writes" it for you where you tell it.