English 中文(简体)
caching per request in ASP.NET?
原标题:

I m using both IBatis.NET and Spring.NET on a project at work and I d like to figure out if I can leverage both/either frameworks to achieve "per-request caching" on all calls into my DAL layer. In other words, every time an HTTP request is served by ASP.NET, I would like first call into a DAL method to hit the remote DB, but all calls thereafter to be inflated from cache.

I ve seen a few articles describe a way to achieve this using HttpContext.Current, but I can t stomach the idea of polluting my DAL layer with System.Web references. I d also like to leverage these frameworks if at possible as I m not fond of re-inventing the wheel.

最佳回答

I m no expert on IBatis.NET and integration with Spring.NET most likely more thank lacking but here goes..

I would create a custom ICache implementation that uses HttpContext.Current.Items. Then I would make DAL layer objects proxied with Spring.NET AOP (they are behind interfaces, aren t they?). Then it s just a matter of applying the cache advice using the AOP framework.

You should be able to do this by following Spring.NET documentation about AOP caching and implement the ICache using Spring.NET s ASP.NET cache implementation as starting point.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签