简单用例的缓存与 HashMap
这必须是一个非常基本的:- 只是好奇,如果我不需要分布式缓存即排序模型,为什么我们需要第三方缓存库(ehcache、memcached),而您所需要的只是(对于简单的用例)只是一个键值对持有者,比如 HashMap ?
This must be a very basic:- Just curious, If I don't need distributed, cache-as-sor models, why do we need third party cache libraries (ehcache, memcached) when all you need (for simple use case) is just a key-value pair holder, something like HashMap ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
生产软件需要花费很多心思,其他人的更多思考和测试(和修复)可以提高软件的价值,并验证代码作为模型的有效性(我并没有说是一个好的模型)。
对于上面的示例,您将如何处理“旧”缓存项的删除?您必须添加更多代码/功能以确保缓存可以被清空。
对于一个简单的程序来说,使用内存缓存可能有点大材小用,但它已经解决了您将遇到的许多问题,并为您提供了一些额外的能力。
我还会使用 Redis 作为示例。您可以用自己的语言做很多事情,但有时,Redis 会让其他事情变得更容易。
嗯嗯!
-丹尼尔
A lot of thought goes into producing software, and the more thought and testing by others (and fixes) improves the value of the software and also validates the code as a model (I didn't say a good model).
For the example, above, how would you handle the deleting of "old" cache items? You would have to add more code/features to insure that the cache could be emptied.
Using memcache may be overkill for a simple program, but it's already solved many of the problems that you will have and gives you a bit of extra ability.
I would also use Redis as an example. You can DO a lot of stuff in your own language, but sometimes, Redis would make other items easier.
YMMV!
-daniel