Answer the question
In order to leave comments, you need to log in
How to store data in Redis?
Good afternoon.
There is an application on ROR, the following task arose: you need to send notifications to the client (mobile application) and wait for confirmation, if there was no confirmation within 5 seconds, repeat the notification. There are no problems with sending - everything works. Redis decided to keep the notification until confirmation, and when the client sends confirmation, remove them from the resend queue. The catch is how to store in Redis. What is the problem: to determine the need to resend, a background task is launched every second, and if the sec field of the notification matches Time.now.sec % 5, then it needs to be sent. Thus, to send, you need to select by the sec field, and when the client sends a confirmation, you need to find it by the type of notification and the user (user_id).
Conclusion: it turns out we need two different keys!I sketched a variant with a full enumeration and data recovery in a hash - but it's very slow. There is another option to just match by string without JSON.parse - it should be faster, but it also seems not very correct.
Maybe Redis has some options for such cases? Or is the problem in the solution itself?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question