【发布时间】:2012-05-22 02:51:24
【问题描述】:
我需要在 Asp.net Web 应用程序中实现缓存 我需要存储具有不同 ID 的数据。 那么哪种方法更好呢?
-
使用字典变量。插入数据(键为ID,数据为值)。
Dim mDict As New Dictionary(Of String, String) mDict .Add(bID, uwtTree.WriteXmlString(True, True)) Cache.Insert("mTree", mDict)将其添加到缓存变量中。 访问缓存变量
If Not Cache("mTree") is Nothing Then 'cast to dictionary and check ID exists , if exsitis get the data End iF -
为不同的 ID 使用缓存变量
Cache.Insert(ID,data) ' each insertion for each ID If Not Cache(ID) is Nothing Then ' get the data. ' End IF
哪种方法是最好的方法?或者还有其他方法存在吗? 我正在使用 .Net 3.5 /IIS 7 (VB.Net)。提前致谢
提高性能和内存优化的方法
【问题讨论】:
-
什么更好?表现?内存消耗?可读性?便于使用?本地化?还有什么?
-
@Oded 性能和内存。
-
测试这两种方法 - 使用性能和内存分析器找出哪一种更适合您的用例。
-
@Oded k.我现在正在做。正是专家的建议。
标签: asp.net .net vb.net caching