[英]MSR Orleans - How to create a reader-writer grain with parallel reads
I need a reader-writer grain(s?) to hold some values so other parts of the system can reference them frequently and in parallel. 我需要一个读写器粒子(s?)来保存一些值,以便系统的其他部分可以频繁地并行地引用它们。
What I'm after is storing some system-wide config values which are accessed frequently, and subject to change, but only extremely rarely (once a month or so at most). 我所追求的是存储一些系统范围的配置值,这些配置值经常被访问,并且可能会发生变化,但非常罕见(最多每月一次)。 The system should be reconfigurable without downtime. 系统应该可以重新配置,无需停机。 What I'm currently considering is to store the data in some database. 我目前正在考虑的是将数据存储在某个数据库中。 Then it will be read at silo startup, and there will be a special callback to read the data again after it changes externally. 然后它将在silo启动时读取,并且会有一个特殊的回调函数,在外部更改后再次读取数据。 I don't want to read the data from the database every time I need it because: 我不想每次需要时都从数据库中读取数据,因为:
I can easily create a reader-writer locked in-memory data store, but Orleans' single-threaded execution policy doesn't allow parallel access to the grain that holds the data. 我可以轻松地创建一个读写器锁定的内存数据存储,但奥尔良的单线程执行策略不允许并行访问保存数据的粒度。 I can think of the following ways to bypass this: 我可以想到以下几种方法来绕过这个:
Suggestions? 建议?
Have you looked at something like the Smart cache pattern ? 您是否看过类似智能缓存模式的内容 ?
Perhaps using a Reentrant
grain could help as well, this will allow method calls to interleave. 也许使用Reentrant
grain也可以提供帮助,这将允许方法调用交错。
I found this issue on github asking for the same. 我在github上发现了这个问题 。
We found a solution that doesn't require timer-based updates over on GitHub . 我们在GitHub上找到了一个不需要基于计时器的更新的解决方案。 I'll detail the solution here: 我将详细解释这里的解决方案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.