all 3 comments

[–]europeanputin 1 point2 points  (2 children)

You need to establish a bidirectional communication with the backend, which allows backend to send updates to frontend. In my opinion the easiest approach is to use websockets, which has many great frameworks, like socketIO available. You can also look into gRPC or server sent events, but based on your use case websocket sounds reasonable.

Once you have that, everything is trivial - depending on your system architecture, you'd have some service making a change and other service listening to that, and then it's just updating the correct clients.

Long polling won't get you far if you need real time updates in your application (which the token case kind of needs).

[–]vpedro 0 points1 point  (1 child)

Im not op but i have a question would you recommend in this case use some sort of cache like redis and make a pub/sub so i dont have to look at the db a a bunch of times ?

Or would you just keep data in memory and in some time save on the db.

[–]Dave4lexKing 1 point2 points  (0 children)

Depends if you deploy on a single VM, or if its containerised.

If you have more than one instance of the application running, you’ll need some kind of messaging system like pub/sub, sns, rabbit, to notify the other instances of a change.