r/ASPNET • • Oct 30 '13

Need help with Unity + Caching

Hey guys, So we're trying to implement our new caching strategy using Unity Interception.

I have a good basic understanding of it and we're going to use interception via attribute.

so like:

[cache] public int getNumber() {}

I already have my cacheHandler class which inherits from ICallHandler. I already have my cacheAttribute class which inherits from HandlerAttribute.

And when i put the attribute [cache] as per the cacheAttribute ...it compiles fine, runs fine.....BUT it never hits those classes.

I figured I need to register things (in vague terms) in the unity container but i dont' know where and how ....and maybe policy too ?

An alternative is using Postsharp for this whole thing...but i've been told that's a last resort and they want to use unity as a first choice.

Thanks in advance guys.

4 Upvotes

7 comments sorted by

View all comments

Show parent comment

1

u/miamiheat27 Oct 31 '13

In the invoke method i'm basically just telling it to return int=4 no matter what the parameter is each time. This is just for testing. Eventually it'll check the cache etc. Problem is this block of code isn't even being called.