[英]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.