Pau*_*les 4 asp.net caching outputcache
我正在调查MVC3源并遇到以下(在OutputCacheAttribute.cs中),在生成用于输出缓存的键时调用它:
// 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())));
}
Run Code Online (Sandbox Code Playgroud)
评论说需要使用哈希,因为"密钥通常太长而无法使用".任何人都可以阐明这一点,并建议在asp.net中缓存键的最大长度?