I'm facing a very simple scenario that should have a simple solution, but can't seem to figure it out.
I'm trying to design a RESTful app that replaces a (stateful) remote for an electrical appliance. The frontend of the app simply shows the current state of the appliance and sends a new state to the backend if the user wishes to change it.
The backend server simply accepts either a GET request to which it responds with the state that was last set or a POST request that sets the state by issuing a command to the appliance (over a serial port).
What puzzles me is how to save the state of the appliance here. Server private memory is out of the question since multiple server processes can be spawned, a disk access for every key-press seems inefficient, and the state message has to pass through to the appliance before the state is advanced on the server.
Anything I think of is either platform-specific (e.g. involving POSIX message queues) or overly complex, but I just feel like this is a common enough problem that it has to have an associated design pattern. That's why I decided to come here and ask for advice before starting to over-complicate things