在网络中实施缓存
我正在开发一个可用于外部互联网连接速度较慢的小型网络的应用程序。
我的应用程序将在该网络中的每个主机上运行,当我请求 URL 时,它将搜索自己的缓存和相邻系统的缓存,如果找不到,则搜索外部网络。我应该如何实施它?我想到了类似的东西:
- 每个主机上的一个端口,用于侦听缓存请求
- 每个缓存数据的内存中缓存表
- 正常的缓存搜索过程
任何改进此架构的指针。
I am developing an application which could be used in small networks where the external internet connectivity is slow.
My application will run on every host in that network and when I request a URL, it would search its own cache and caches of adjacent systems and if not found then search the external web. How should I go about implementing it? I have thought of something like:
- A port on every host to listen for caching requests
- An in-memory cache-table for every cached data
- Normal cache-search procedure
Any pointers to improve this architecture.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论如何,开发自己的缓存,但可能值得首先查看其他非常流行的示例。我建议看一下 squid。
如果您确实想构建自己的缓存,则可以考虑使用分布式缓存,例如 ehcache。它将缓存的完整副本复制到每个节点。就您而言,您可能只想向 ehcache 提供有关 URL 以及数据存储在哪台计算机上的信息。这不会限制您使用相邻的系统。
By all means develop your own cache, but it's probably worth looking at other very popular examples first. I would suggest taking a look at squid.
If you really want to build your own, you could think about using a distributed cache like ehcache. It replicates an entire copy of the cache to every node. In your case, you might only want to give ehcache information about URLs and which machine the data is stored on. That wouldn't limit you to adjacent systems.