Answer the question
In order to leave comments, you need to log in
Is it possible to store such data in Redis?
In a laravel application, I want to show the user information about who is currently viewing a particular page.
In Redis, I'm going to save information in this format: {'/item/35': {1: last_visit_time_in_seconds}}
If two more users visit the /item/35 page, then Redis will have
{'/item/35': {1: seconds}, {12: seconds}, {2425: seconds}}
{1: seconds}
within 30 seconds, then information about him should be removed from the cache, but the record about other users should remain. The frontend periodically sends requests to the backend to maintain the state of the cache. Answer the question
In order to leave comments, you need to log in
You can do this:
When the user opens the page, create an entry in redis with the TTL you need using SETEX.
The key is something like this: opened:item_35:user_id. The value doesn't matter.
To find out the users on this page, make the request keys opened:item_35:* and parse the user_id from the received keys.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question