开发者

Is using SessionID + MemoryCache in ASP.NET safe and good design?

For each of the user that logs in to my ASP App, they will do some query from database. To lower the traffic I want to cache each of their query result for like 10~ 30 seconds, so when the same user requests same query during the duration they will get their result directly back from the cache.

But because MemoryCache is gobal, I wonder if I do:

MemoryCache UserMemoryCache = new MemoryCache(MySession.SessionID);

Wil开发者_开发问答l that be safe and is this good design? Should I just simply cache in session?


Session space is readily available for just such a purpose. All you are really doing is keeping track of pointers to your data objects/values, so creating a new object instance to do this increased overhead (granted, not by much) but if you can accomplish the same goal with the existing infrastructure (in this case, the session reference) then do so.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜