Reputation: 1022
I am experimenting real time app using Laravel and socket.io. I make a seperate node and redis server. Now I see several tutorials introducing redis to subscribe to channels. But I try without redis and socket.io is able to connect and emit etc.
The question is, what is redis used for and are there any specific scenarios that redis is able to handle that socket.io can't?
Thank you.
Upvotes: 0
Views: 3538
Reputation: 86
Socket IO helps in communicating between two different browser tabs, and that do not have anything to do with Laravel application only using socket.js file. So when you want to communicate between Laravel application and browser like chat or real time notifications about the events that happen in laravel application, then Redis will help you.
Laravel application send the data to Redis and Redis pass data to socket IO, then socket IO sends data to browser.
This is similar to AJAX, but in ajax the client ask for data and server/ laravel application responds to the AJAX request.
In our case the server it self can send updated data, as the change happens with out browser requesting, so this is helpful because the browser does not when the data is updated on the server side.
When I started learning socket IO and Redis I struggled a lot to find and understand this, hope this helps you.
Upvotes: 5