So I am developing an app where orders come into a queue where the queue is then worked off of by a group of users. I dont want 2 users to be able to view the same order at the same time as that could obviously cause some problems. I am doing some research but have never really done anything like this so I would like some input from people that have built something similar and the way you implemented it. Currently what I am looking at implementing is a Redis cache on my laravel server.
Extra Info
- Using Laravel backend and Vue 3 front end
- NEED viewing data (whose viewing what) to be able to be loaded on a page reload
- NEED to be able to push live updates of viewing data to active users (I am using pusher currently to push events to front end users)
If you need more information I am more than happy to answer or clarify anything in the comments.
CodePudding user response:
This might be a little vague, but we have something similar in our ticketing system app. What we do is raise a flag 'locked' for the specific ticket that is being viewed. So we have two columns called lock_status and locked_by for each ticket in the database. When a user clicks the open button, it automatically sets the lock_status=1 and locked_by=(user ID). Secondly, we use an ajax function to constantly check if the ticket is locked or not. The function runs after every 30 seconds. If the lock_status=1 and the locked_by is not equal to the user ID who is viewing the ticket, we simply redirect him with a message that this ticket is currently being viewed by user : (user ID and email). You can modify the requirements to suit your need. Sounds like you do not need to show who is viewing it. Just redirect him. You can schedule ajax calls using setInterval() method. An example: how to schedule ajax calls every N seconds?