简体   繁体   English

Asp.Net如何在同一应用程序池中运行的应用程序之间共享缓存中存储的数据

[英]Asp.Net How to share the data stored in cache across applications running in same application pool

Right now I am storing some data in memory using ObjectCache in web api. 现在,我正在使用Web API中的ObjectCache在内存中存储一​​些数据。 But I need this data to be accessed by another web api running in the same application pool. 但是我需要由运行在同一应用程序池中的另一个Web api访问此数据。 Please advise. 请指教。 I am using IIS 8.5. 我正在使用IIS 8.5。

I recommend you to avoid that complex things, since you will have too much pain sharing memory across the pool/memory of differents apps. 我建议您避免这些复杂的事情,因为在不同应用程序的池/内存之间共享内存会带来太多痛苦。

Is not possible that you create a webservice as an cache for the n-applications you want to share? 您是否无法将Web服务创建为要共享的n个应用程序的缓存? In that webservice you could use anything you think fits best for storing in memory 在该Web服务中,您可以使用最适合存储在内存中的任何内容

[HttpGet("set/{keyname}/{data}")]
public IActionResult SetData(string keyname,string data)
{
    HttpContext.Session.SetString(keyname, data);
    return Ok("session data set");
}

[HttpGet("get")]
public IActionResult GetData(string keyname)
{
    var sessionData = HttpContext.Session.GetString(keyname);
    return Ok(sessionData);
}

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

相关问题 从同一个池中的asp.net应用程序以编程方式回收池 - programatically recycle pool from asp.net application in same pool ASP.NET应用程序池回收是否会刷新静态对象上的缓存? - Will ASP.NET application pool recycling refresh a cache on a static object? 在同一IIS上的ASP.NET应用程序之间共享信息 - Share information beetween ASP.NET applications on the same IIS 应用程序池Asp.net - Application pool Asp.net 如何在Windows Azure上设置站点/应用程序以共享同一应用程序池 - How to set up sites/applications to share same Application Pool on Windows Azure 如何在 IIS 7、Windows 7 上将 ASP.NET 4.0 添加为应用程序池 - How to add ASP.NET 4.0 as Application Pool on IIS 7, Windows 7 如何在 Z5267A5EC9705EB7AC2C984033E06189DZ 应用程序 asp.net 和 asp.net 内核之间共享一个简单的字符串值(配置)? - How can I share a simple string value (config) between two web applications asp.net and asp.net core in IIS? 使用具有特定标识的应用程序池运行 ASP.net 项目会产生“(403) Forbidden” - Running an ASP.net project with an Application Pool with a specific Identity yields "(403) Forbidden" 跨多个Web应用程序的Asp.Net共享会话? - Asp.Net sharing session across multiple web applications? 在.NET 2.0应用程序池中运行ASP.NET 4应用程序 - Running a ASP.NET 4 app in .NET 2.0 app pool
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM