开发者

How to handle BL cache for multiple web applications?

I recently received a project that contains multiple web applications with no MVC structure. For开发者_StackOverflow中文版 starters I've created a library (DLL) that will contain the main Business Logic. The problem is with Caching - If I use the current web context cache object than I might end up with duplicate caching (as the web context will be different for every application).

I'm currently thinking about implementing a simple caching mechanism with a singleton pattern that will allow the different web sites (aka different application domains) to share their "caching wisdom".

I'd like to know what is the best way to solve this problem.

EDIT: I use only one server (with multiple applications).


Depending on the type and size of the data you want to cache, I'd suggest:

  1. For small amounts of primitive data : nCacheD (codeplex) - memcached redux for .net
  2. For heavyweight objects : MS Patterns and Practices Caching Block (msdn)

In general though, I would look at my requirements and make really sure an all-encompassing cache is really needed, and writing code to maintain its state (and tune its resource consumption) would not be more expensive than going straight to the database. If most of the stuff you want to cache is static pages, or a combination of static & dynamic content, I would look into utilizing IIS/ASP.NET's page level cache.


I have two different suggestions depending on your plans to be scalable. Regardless of the back end cache you choose i would suggest that you first implement an adapter pattern layer that abstracts you from your cache, as a result it will limit your dependency on the cache and give you the ability to swap it out later.

If you want to scale out by adding a web farm (more than one application server) then look at velocity. Microsoft will be packaging this in 4.0 but it is a CPT3 currently and is very easy to use.

Documentation

Download

If you dont plan to move to a multiple server system then just use the HttpContext.Current.Cache


Sounds to me like you should take a look at Build Better Data-Driven Apps With Distributed Caching. The article describes a new, distributed cache from Microsoft (codenamed Velocity).


I've also been offered to use SharedCache, which look exactly like the architecture I'm looking for: Single Instance Caching.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜