节点之间的 Erlang Ets 表
我有一个 ejabberd 服务器,其中运行着大量自定义模块。我有几个 mnesia 表,我知道这些表可以在节点之间轻松复制,而无需对代码进行任何更改。我想知道 ets 表是否有类似的方法?
理想情况下,如果能够让多台机器运行完全相同的 mnesia 和 ets 数据,而不必将我的 ets 表转换为 mnesia 表,那就太好了。 (因此重写了大量代码。)
虽然我有一个方法是在每个节点的 ets 表上执行 rpc:call,但我不确定这会对性能产生影响。
如果有人有任何答案请告诉我。
I've got an ejabberd server with a good amount of custom modules running. I have several mnesia tables and I know these can be easily copied between nodes without any change to the code at all. I was wondering if there's a similar way with ets tables?
Ideally it'd be nice to be able to have several machines running with exactly the same mnesia and ets data, without having to convert my ets tables into mnesia tables. (And thus rewriting a good amount of code.)
One though I had was doing an rpc:call on the ets tables for each node, but I was unsure about the impact this would have on performance.
If anyone has any answers please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不可以,无法为您复制 ets 表内容。
复制(和事务安全)是 mnesia 数据库应用程序引入的功能,其实现对 ram_only 表使用 ets。
No, ets table contents can not be replicated for you.
Replication (and transaction safety) is the feature that the mnesia database application introduce, its implementation uses ets for ram_only tables.
您可以 rpc:call 远程节点上的 ets 表。
但 mnesia 的全部意义在于解决您遇到的问题:复制
将代码转换为 mnesia 是对未来的一项良好投资。
虽然存在风险,但您始终可以使用
mnesia:ets()
来最大限度地减少代码更改。You could rpc:call on the ets tables on the distant node.
But the whole point of mnesia is fixing the kind of problem you're running into : replication
Converting your code to mnesia is a good investment for the future.
And while risky, you could always use
mnesia:ets()
for minimizing code change.