Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any Free Alternative to PostSharp [closed]

The application we are building sends out different kind of emails regularly. I stored the email templates in an Azure blob storage and the methods responsible for sending emails pull the appropriate email templates from there. I want the templates to be outside of the hosted service in case I want to update it, I can do that simply by uploading new templates to the blob.

The problem I'm having, from performance and cost perspective, is that the email templates rarely change within a 24hr period. So caching the method in a way akin to [OutputCache(Duration = duration, VaryByParam = "id")] in ASP.NET MVC will be an ideal solution in order to increase the worker role performance. How to do this is now a problem. I learnt of PostSharp but our budget didn't take PostSharp's licencing fee into consideration from the beginning!

Any other free alternatives? Thanks for helping out.

like image 288
olatunjee Avatar asked Jan 02 '13 01:01

olatunjee


3 Answers

PostSharp Starter Edition is free and would meet your requirements.

like image 89
Gael Fraiteur Avatar answered Nov 13 '22 15:11

Gael Fraiteur


I have implemented method level caching in the past, using the following combination:

  1. Autofac as IoC container
  2. Autofac's MVC3 integration package
  3. Autofac's DynamicProxy2 (castle) integration for interception support
  4. Custom Attribute to decorate classes that require caching support
  5. Custom Interceptor to add method level caching

The custom attribute and interceptor is quite easy to set up. The main problem with method level caching is, I believe, how you determine cache hits and misses in an optimal, yet precise way.

In my case it needed to be generic (support any type of method call and parameters), so I had to create a flexible way to hash all method parameter values in order to distinguish one call from another. But in your case, this could actually be a very specific interceptor, that already knows the structure of your method call, which would make things a lot easier.

Now about the actual caching, you can take advantage of .NET's caching support, available in the System.Runtime.Caching namespace, which already provides a MemoryCache if that's suitable for you.

like image 35
Pablo Romeo Avatar answered Nov 13 '22 15:11

Pablo Romeo


I've used SNAP a few times. It's free and very easy to setup and use with a number of IoC containers

like image 1
MarkG Avatar answered Nov 13 '22 17:11

MarkG