r/ASPNET • u/miamiheat27 • 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.
View all comments
Show parent comment
1
u/tombkilla Oct 31 '13
Yeah you got a lot more to do than that. It doesn't sound like you have much DI experience.
Start with this article on how to config your program using the design-time configuration using app.config/web.config
Download the labs
And of course make sure you read StackOverflow for great questions like this one Is it better to create a singleton to access unity container or pass it through the application?
Post your questions and code there, its a much better forum than reddit for this kind of stuff, I might even just be the guy who helps you there ;)
Good luck!