服务器重启后保留缓存数据
我想使用分布式缓存解决方案,该解决方案将具有缓存备份,以便在服务器重新启动后保留缓存。使用 memcached 是否可以实现相同的目的?
I want to use a distributed caching solution that will have a backup of the cache to retain the cache after server restart. Is it possible to achieve the same using memcached ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
缓存的要点在于它不是主存储。您可能有一个 mysql 数据库,或者可能有外部 api 调用来获取数据。无论您如何设置,您都不应该依赖缓存中的数据。您应该对其进行设置,以便如果您的缓存被刷新,您不应该丢失任何数据。唯一的缺点是最初填充缓存的成本可能会有点高。此外,memcached 会因为一些原因(传递到期日期、完整缓存等)而删除记录,而不会提示您。
所以我真的不会担心重新启动后保持缓存完好无损。如果您有一个 mysql 数据库作为主存储,那么显然在服务器重新启动后仍会保留其数据,而这才是您真正应该担心的。
The point of a cache is that it isn't the primary storage. You might have a mysql database or you might have external api calls to fetch data. Regardless of what your set up, you shouldn't rely on the data in the cache. You should have it set up such that if your cache was flushed, you shouldn't lose any data. The only downside is that it might be a tad costly to fill your cache initially. Additionally, memcached will drop records without prompting you for a handful of reasons (passing of the exp date, full cache, etc).
So I wouldn't really worry about keeping the cache intact after restart. If you have a mysql database as a primary storage, that obviously keeps it's data after a server restart, and that's all you really should worry about.