当基于哈希字符缓存文件时,为什么使用最后一个字符而不是第一个字符?
我看到它建议您通过使用散列文件名的最后一个字符在缓存中获得更好的“负载平衡” - 例如 nginx 就是这样做的(代理缓存模块)。谁能解释为什么使用最后一个字符?
编辑:
例如:
md5('asdf')
'912ec803b2ce49e4a541068d495ab570'
md5('asdg')
'7e6a6a87bf3ffb29a6dd9f14afdc3b88'
“似乎”足够随机。
I have seen it suggested that you get better "load-balancing" within a cache by using the last characters of a hashed filename - it's what nginx does for example (proxy cache module). Can anyone explain why the last characters are used?
EDIT:
For example:
md5('asdf')
'912ec803b2ce49e4a541068d495ab570'
md5('asdg')
'7e6a6a87bf3ffb29a6dd9f14afdc3b88'
"seem" random enough.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很多文件以相同的前缀开头是很常见的。通过反转名称可以增加随机性。
It's common to have lots of files that start with the same prefix. By reversing the name you can increase the randmoness.