在HttpRuntime.Cache缓存键的最大长度的对象? [英] Maximum length of cache keys in HttpRuntime.Cache object?
问题描述
我们正在使用HttpRuntime.Cache API在ASP.NET从数据库中检索缓存数据。
We are using HttpRuntime.Cache API in an ASP.NET to cache data retrieved from a database.
有关这个特殊的应用,我们的数据库查询功能的参数很多,所以我们的缓存键是这个样子:
For this particular application, our database queries feature a LOT of parameters, so our cache keys look something like this:
table=table1;param1=somevalue1;param2=somevalue2;param3=somevalue3;param4=somevalue4;param5=somevalue5;param6=somevalue6...等等...
table=table1;param1=somevalue1;param2=somevalue2;param3=somevalue3;param4=somevalue4;param5=somevalue5;param6=somevalue6... etc...
对于某些查询,我们有这么多参数缓存键长几百个字符。
For some queries, we have so many parameters that the cache key is several hundred characters long.
我的问题:是否有对这些缓存键的长度有限制吗?内部,它是用一个字典,所以理论上的查找时间应该是恒定的。然而,不知大家有潜力碰到一些性能/内存问题。
My question: is there a limit to the length of these cache keys? Internally, it is using a dictionary, so theoretically the lookup time should be constant. However, I wonder if we have potential to run into some performance/memory problem.
推荐答案
在内部,字典使用你给它的密钥的散列code。每一个有效的密钥被存储为整数。
Internally, Dictionary uses the hash code of the key you give it. Effectively every key is stored as an integer.
您有什么可担心的。
这篇关于在HttpRuntime.Cache缓存键的最大长度的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!