Is there a way to open shared memory block with Ruby, equivalent to shmop_open
in PHP?
I have one process periodically update a memory block. My Rails app needs to read those data.
Is there a way to open shared memory block with Ruby, equivalent to shmop_open
in PHP?
I have one process periodically update a memory block. My Rails app needs to read those data.
You have a few options as gems, but I've never used them myself.
sysvmq implements System V IPC message queues.
posix-mqueues implements POSIX message queues.
Maybe try hammerspace
We use this as a caching layer for translations and configurations on our production machines.
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.
See https://github.com/airbnb/hammerspace