Sharing CacheManager across multiple applications on the same machine

Topics: Caching Application Block
Sep 17, 2008 at 11:08 PM
Edited Sep 18, 2008 at 12:25 AM
BACKGROUND:

I am evaulating the Caching Application Block (CAB) for our production environment:

- a pair of load-balanced IIS web servers
- a third server which runs a few dozen services and scheduled tasks
- a fourth server which runs the database

We will mainly be caching small, frequently-accessed tables from database that store business metadata (they need to be in the database to support reports, so we figured we might as well use them in our application code to avoid redundancy, and use caching to improve performance.)

QUESTION:

Suppose I use the CacheManagerFactory(IConfigurationSource) constructor to get a factory object that will produce CacheManager objects based on a configuration source.  I do this from several different executables, but always use the same configuration source, and when I call the CacheManager's Create() method, I always use the same name.  In this case, is the cache common to all the executables?  In other words, if I add something to the cache from one executable, and attempt to read it from the cache from a different executable, will it exist?

I am not too concerned about the web server because, as I understand IIS, each web application is usually served from its own long-running process, so the CAB cache will be common to all requests from the same web application.  I am mainly concerned about our third "services / scheduled task" server, where many different executables will frequently execute for a few minutes and terminate.  If they all used a different cache, I believe the efficiency of the system would be greatly reduced.

Jordan Rieger
Sep 18, 2008 at 1:17 AM
If I recall correctly, the default out of the box implementation cannot be shared across different application domains. You have a couple of shared cached managers you can check out (no particular order): NCache, Velocity or indeXus.Net Shared Cache.
Sep 24, 2008 at 11:00 PM
Thanks for the reply.  I was expecting this, because I remembered reading about how the cache is not shared across different application domains, but I wasn't entirely clear on the concept of application domains.  I did some research and I have a better understanding now.  I've heard of NCache but I will check out the other two solutions you mentioned.  We may still use CAB because free, easy-to-implement caching, even if the cache is not common among all processes, is better than no caching at all.  Most of our services and scheduled tasks operate in a repetitive fashion on medium to large data sets, so caching the business metadata will definitely improve performance.

Jordan Rieger