Ruby 打开共享内存块 [英] Ruby open shared memory block
问题描述
有没有办法用Ruby打开共享内存块,相当于PHP中的shmop_open
?
Is there a way to open shared memory block with Ruby, equivalent to shmop_open
in PHP?
我有一个进程定期更新一个内存块.我的 Rails 应用需要读取这些数据.
I have one process periodically update a memory block. My Rails app needs to read those data.
推荐答案
也许可以试试 hammerspace
我们将其用作生产机器上翻译和配置的缓存层.
We use this as a caching layer for translations and configurations on our production machines.
你可以有一个进程定期更新hammerspace文件,然后所有的rails进程都可以使用它.当 hammerspace
访问该文件时,该文件会进行内存映射,因此它实际上是共享内存.
You can have one process that periodically updates the hammerspace files, and then all the rails processes can consume it. The file gets memorymapped when hammerspace
accesses it, so it is defacto shared memory.
参见 https://github.com/airbnb/hammerspace
这篇关于Ruby 打开共享内存块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!