Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  158] [ 7]  / answers: 1 / hits: 17597  / 13 Years ago, fri, june 10, 2011, 12:00:00

Is there a way to directly connect to Redis using client side (not Node.js) javascript?



I'm already using Node.js + PHP + Redis + Socket.io (for the client) successfully for a few projects. However, I really think this could be further simplified to something like PHP + Redis + Browser javascript - taking out the Node.js server which is just another server I'd rather not use if it isn't necessary. For simple things, I think it would be better to just connect directly to Redis using Javascript.



From what I understand, Redis just serves its request through a port so any language that can make requests to that port would work. In theory, couldn't you just hit the redis server's port using client side javascript?



I'm mostly interested in the publish/subscribe functions, which may or may not be possible.



I'm not sure if you can access a non-port 80 port using AJAX, but you technically should be able to forward Redis' port to port 80 using Nginx reverse proxy or something.



Any ideas? Just a thought. I'm very happy with my current solution, but it doesn't hurt to wonder if we could do this even better or more efficiently.


More From » php

 Answers
52

You can only make HTTP and websockets requests with client-side JavaScript. However, you should look into Webdis. It adds an easy HTTP/JSON layer to Redis and should do exactly what you want.


Edit: Link fixed.


[#91761] Thursday, June 9, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
saiget

Total Points: 64
Total Questions: 105
Total Answers: 105

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
;