简体   繁体   English

在一个解决方案中在项目之间共享缓存

[英]Share cache among the projects in one solution

I have an solution with 4 projects and I need to share cache among the 4 projects. 我有4个项目的解决方案,我需要在4个项目之间共享缓存。 is it possible in .net? .net有可能吗?

In projet A 在projet A中

   public static CacheManagerClass{

    public static T GetCache<T>(string key) where T : class
    {
     object cachedObject = HttpRuntime.Cache.Get(key);
    return cachedObject ;
    }
    }

this is a sample of method i used to retrieve the cache object. 这是我用来检索缓存对象的方法的示例。 and the cache is created by an MVC application.I need to access the same cache using a wcf 并且缓存是由MVC应用程序创建的。我需要使用wcf访问相同的缓存

在其他3个项目引用的项目中创建缓存并使用它?

If i understand correctly, you are trying to reference the cache class from 3 (or 4) different executables. 如果我理解正确,则您尝试从3个(或4个)不同的可执行文件引用缓存类。 This cannot be done because each process loads it own instance of the cache class from the DLL. 之所以不能这样做,是因为每个进程都从DLL加载它自己的缓存类实例。

You probably need to create some cache service (using WCF for example) which runs on another process (or on one of the existing processes) in order to manage caching for the multiple processes. 您可能需要创建一些缓存服务(例如,使用WCF),该服务在另一个进程(或现有进程中的一个)上运行,以便管理多个进程的缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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