简体   繁体   中英

Share Cache among instances

I have a application and I cache several data for it (.net cache). Normally this application runs using 2 or 3 instances.

Whenever a new instance is created to handle request, the memory usage become double. I am wondering if every new instance creates its own cache.

Is it true? if yes, is there a way to share the cache among the instances of the same application?

Thanks in advance for sharing the valuable knowledge!

EDIT :

Language c# Please see below for example how we cache :

System.Web.HttpContext ctx
            = System.Web.HttpContext.Current;
  ctx.Cache.Insert("siteViewModel", siteViewModel, null,
DateTime.Now.AddHours(Int32.Parse(siteViewModel.ApplicationSettings["dtoCacheDurationHours"])), System.Web.Caching.Cache.NoSlidingExpiration,
                 System.Web.Caching.CacheItemPriority.Default, OnCachedItemRemoved);

I haven't played with this at all, but I understand that AppFabric offers distributed caching features . You may want to check out some examples like this one .

First I need to tell that you can not use the cache among multiple instance. You can also use the Windows azure caching system also to share the cache across the application and it is easily used using RESTful way.

You can also evaluate Microsoft Velocity for your scenario. Velocity will provide you distributed and in-memory cache.

Link: Build Better Data-Driven Apps With Distributed Caching

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM