What are all the caching options\levels possible in web-application BLL layer
(I understand we can use Session dictionary only in aspx and ascx code behind. right?)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The session is available as a storage medium at any level of an ASP.NET web app, however many of the classes involved in accessing it are sealed and not easily mockable (HttpContext, HttpSessionState, etc) and it is considered bad practice to have your business logic ‘know’ how your application is being hosted. I’d suggest hiding any cache implementations behind a generic ICache interface, which can then be easily switched out if you re-use your BLL in another application.
A few options available to you are:
A per request cache using HttpContext.Items (http://www.4guysfromrolla.com/articles/060904-1.aspx)
A session cache using HttpContext.Session (if your application is load balanced, and you do not have sticky sessions extra work must be done to ensure a consistent session state (eg using SqlSessionState)).
An application cache using HttpContext.Cache or HttpRuntime.Cache (again if your application is load balanced and you do not have sticky sessions extra work must be done to ensure a consistent application cache).
Hope this helps.