用(客户端)javascript直接连接到Redis? [英] Connecting directly to Redis with (client side) javascript?

查看:2251
本文介绍了用(客户端)javascript直接连接到Redis?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用客户端(不是Node.js)javascript直接连接到Redis?

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

我已经在使用Node.js + PHP + Redis + Socket.io(对于客户端)成功完成了一些项目。但是,我真的认为这可以进一步简化为PHP + Redis + Browser javascript - 取出Node.js服务器,这是另一台服务器,如果没有必要,我宁愿不使用。对于简单的事情,我认为最好使用Javascript直接连接到Redis。

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.

根据我的理解,Redis只是通过端口提供请求所以任何语言可以向该端口发出请求会起作用。理论上,你不能只使用客户端javascript命中redis服务器的端口吗?

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.

我不确定您是否可以使用AJAX访问非端口80端口,但从技术上讲,您应该能够将Redis的端口转发到端口80使用Nginx反向代理或其他东西。

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.

推荐答案

您只能使用客户端JavaScript以及在某些浏览器中使用websockets进行HTTP请求。但是,您应该查看 Webdis 。它为Redis添加了一个简单的HTTP / JSON图层,并且应该完全符合您的要求。

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

编辑:链接已修复。

这篇关于用(客户端)javascript直接连接到Redis?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆