简体   繁体   English

后端缓存密钥真的需要被哈希?

[英]backend cache key really need being hashed?

I'm retrieving data from db and save it in cache under a key = user.id.1 我正在从db中检索数据并将其保存在key = user.id.1下的缓存中

I saw people using md5(key) or salt . md5(key) 我看到人们使用md5(key)salt . md5(key) salt . md5(key) and advising to don't use stronger encryptions methods to don't add overhead. salt . md5(key)并建议不要使用更强的加密方法来增加开销。

If someone wants to access your cached data needs access to server, md5 is easily cracked these days, a salt seems to be pointless in this case and hashing the key will still not help with key collision if is the same key. 如果有人想要访问你的缓存数据需要访问服务器,这些天很容易破解md5,在​​这种情况下,盐似乎毫无意义,如果是相同的密钥,则密钥的散列仍然无法帮助解决密钥冲突。

What's the reason to use a hash for the key? 使用哈希作为密钥的原因是什么?

Thanks 谢谢

In my opinion there is no need to do that for short keys. 在我看来,没有必要为短键做到这一点。 Hashing would be good if you're going to cache for example a long select query. 如果您要缓存例如长选择查询,则散列将很好。 It'll be better to keep 32 chars instead of long 200 chars. 保留32个字符而不是长200个字符会更好。 If you use hash for short key, you will have 32 chars instead of 7 or 10 chars. 如果你使用哈希作为短键,你将有32个字符而不是7或10个字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM