在asp.net缓存密钥长度 [英] Cache key length in asp.net
问题描述
我正在调查MVC3源碰上了如下(OutputCacheAttribute.cs)被称为生成密钥用于输出缓存时:
I was investigating the MVC3 source and came across the following (in OutputCacheAttribute.cs) which is called when generating a key to use for output caching:
// The key is typically too long to be useful, so we use a cryptographic hash
// as the actual key (better randomization and key distribution, so small vary
// values will generate dramtically different keys).
using (SHA256 sha = SHA256.Create()) {
return Convert.ToBase64String(sha.ComputeHash(Encoding.UTF8.GetBytes(uniqueIdBuilder.ToString())));
}
该评论说,使用哈希是必需的,因为关键是典型过长是有益的。任何人都可以揭示出这个光与推荐缓存键的最大长度在asp.net?
The comment says that the use of a hash is required because "The key is typically too long to be useful". Can anyone shed light on this and recommend a maximum length for cache keys in asp.net?
推荐答案
长度实际上并不事情,因为它转换为一个散列。
这适用于MVC和ASP.NET。
The length doesn't actually matter as it is converted to a hash. This applies to MVC and ASP.NET.
<一个href=\"http://stackoverflow.com/questions/2330621/maximum-length-of-cache-keys-in-httpruntime-cache-object\">Maximum在HttpRuntime.Cache缓存键的长度反对呢?
这篇关于在asp.net缓存密钥长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!