使用 EHCache 的分布式持久缓存
我目前有一个通过 RMI 使用 EHCache 的分布式缓存,效果很好。我想知道是否可以将持久性包含在缓存中以创建分布式、持久性缓存。
除此之外,如果缓存是持久的,它是否会从文件存储加载,然后从缓存集群引导?基本上,我想要的是:
- 缓存启动
- 缓存从文件存储加载持久对象 Cache joins the distruted cluster and bootstraps as normal
这背后的用例是让 2 个相同的组件在独立的计算机上运行,分配缓存以避免在其中一个组件发生故障时丢失数据。这种持久性可以防止在两个组件都发生故障的罕见情况下丢失所有数据。
转向另一种分发方法(例如 Terracotta)会支持这一点吗?
I currently have a distributed cache using EHCache via RMI that works just fine. I was wondering if you can include persistence with the caches to create a distributed, persistent cache.
Alongside this, if the cache was persistent, would it load from the file store, then bootstrap from the cache cluster? Basically, what I want is:
- Cache starts
- Cache loads persistent objects from the file store
Cache joins the distruted cluster and bootstraps as normal
The usecase behind this is having 2 identical components running on independent machines, distributing the cache to avoid losing data in the event that one of the components fails. The persistence would guard against losing all data on the rare occasion that both components fail.
Would moving to another distribution method (such as Terracotta) support this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会看一下 EHCache 中的 直写式缓存选项。如链接中所述,组合读通缓存和后写缓存将为用户定义的数据存储提供持久性。
Terracotta 为您提供的是一致性(因此您不必担心解决集群成员之间的冲突)。您可以选择定义自己存储的接口(通过 CacheLoader 和 CacheWriter 或只是让 Terracotta 保留您的数据,但我从 Terracotta 和文档中收到了混合信号TC 是否适合记录系统 如果您的数据是瞬态的并且可以随时被清除(例如网络会话),那么可能没问题。
I would take a look at the write-through caching options in EHCache. As described in the link, combining a read-through and write-behind cache will provide persistence to a user-defined data store.
What Terracotta gives you is consistency (so you don't have to worry about resolving conflicts among cluster members). You have the option of defining an interface to your own store (through
CacheLoader
andCacheWriter
or just letting Terracotta persist your data, but I have received mixed signals from Terracotta and documentation on whether TC is appropriate for a system-of-record. If your data is transient and can be blown away at any time (like for web sessions) it might be OK.将 bootstrapCacheLoaderFactory 元素与 cacheEventListenerFactory 添加到缓存(当其他节点关闭时需要从其他节点引导,如果该节点有任何更新,则与其他节点复制)
memoryStoreEvictionPolicy =“LFU”
磁盘持久=“真”
生存时间=“86400”
maxElementsOnDisk="1000">
Adding bootstrapCacheLoaderFactory element along with cacheEventListenerFactory to the Cache(which which needs to bootstrapped from other nodes when it is down & replicates with other nodes if that node got any updates)
memoryStoreEvictionPolicy="LFU"
diskPersistent="true"
timeToLiveSeconds="86400"
maxElementsOnDisk="1000">