I am building a website using Redis as queue/messaging store.
What I am trying to build now is a very basic notification system; What I am doing right now is the following:
//sending notification:
$idIn = idToSendNotificationTo();
$r->rpush("$idIn*notifs", "$myId*likephoto947574")
Considering that on a synchronous system such as PHP, pub/sub is not exactly viable, would this approach still work?
Also, how can I have the receiving user get all the notifications using lists? LPOP gets them one by one and, when the user opens up the webpage, all of the new notifications should popup.
Any advice?
Thanks in advance.
Yes, this approach can certainly work. To pop multiple items from a list, you should use a combination of LRANGE + LTRIM.