本文介绍了在服务器中为所有用户C#缓存我的静态数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在服务器中缓存一些静态数据。如果任何用户请求相同的数据缓存应该返回。



如果我使用HttpContext.cache,它将因用户而异。请帮我在c#中如何做到这一点?



我尝试过:



HttpContext.Cache.Insert(cacheKey,Sonarresult,null,DateTime.Now.AddSeconds(Timeduration),Cache.NoSlidingExpiration);我试过这个但是对于所有用户都将存储到缓存中。我不想要那个。第一个用户只需要存储它。

Hi,

I want to cache some static data in server. if any user request for same data cache should return that.

if i go with HttpContext.cache, it will vary by user. please help me how to do that in c#?

What I have tried:

HttpContext.Cache.Insert(cacheKey, Sonarresult, null, DateTime.Now.AddSeconds(Timeduration), Cache.NoSlidingExpiration); i tried this but for all users will store into cache. i dont want that. first user only has to store it.

推荐答案


这篇关于在服务器中为所有用户C#缓存我的静态数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 12:24