我可以直接在 Javascript 中连接 Redis 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2879305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can i connect Redis directly in Javascript?
提问by remus
ditto, i take a tour of Node.js, another way?
同上,我以另一种方式参观了 Node.js?
回答by dgorissen
The question is poorly formulated, but in case anybody is interested in accessing redis from client side javascript see this SO question
这个问题的表述很糟糕,但如果有人有兴趣从客户端访问 redis javascript,请参阅此 SO 问题
回答by chakrit
There's a Redis binding for Node.js on Github:
Github 上有一个 Node.js 的 Redis 绑定:
http://github.com/fictorial/redis-node-client
http://github.com/fictorial/redis-node-client
and you can try node.js without any need for persistence.
你可以尝试 node.js 而不需要任何持久性。
If you have questions, right now it's best to show up on Freenode #node.js or the mailing list on Google Groups.
如果您有任何问题,现在最好在 Freenode #node.js 或 Google Groups 的邮件列表上显示。
回答by tempestSA
I see http://github.com/fictorial/redis-node-clienthas been abandoned, rather use this http://github.com/mranney/node_redis, it's got good documentation, if combined with the redis commands http://redis.io/commands.
我看到http://github.com/fictorial/redis-node-client已被放弃,而是使用这个 http://github.com/mranney/node_redis,它有很好的文档,如果结合 redis 命令http:/ /redis.io/commands。
回答by adkatrit
Unfortunately javascript can only communicate via HTTP or Websockets.
不幸的是,javascript 只能通过 HTTP 或 Websockets 进行通信。
Here's an idea:
这是一个想法:
Embed a .swf in your page and write javascript callbacks for an actionscript redis client. https://github.com/claus/as3redis
在您的页面中嵌入 .swf 并为 actionscript redis 客户端编写 javascript 回调。 https://github.com/claus/as3redis
This would have less network overhead than implementing something like http://webd.is/or any other server-side redis client.
这将比实现诸如http://webd.is/或任何其他服务器端 redis 客户端之类的东西具有更少的网络开销。
You should be reducing network overhead everywhere possible. While the following may be fast, we may still be able to do better.
您应该尽可能减少网络开销。虽然以下可能会很快,但我们仍然可以做得更好。
step 1 ajax call -> php -> redis
第 1 步 ajax 调用 -> php -> redis
step 2 redis -> php -> ajax return
第 2 步 redis -> php -> ajax 返回
....that's at least two separate tcp connections if your redis server is not on the same server as your backend application.
....如果您的 redis 服务器与后端应用程序不在同一台服务器上,那至少是两个单独的 tcp 连接。
Why not cut out the middle-man and write javascript callbacks to actionscript redis calls?
为什么不切断中间人并编写javascript回调到actionscript redis调用?
Here's why: -You may not want to expose your redis server to the internet. -A client-side dependency on flash for your data retrieval may not be the best solution in terms of robustness.
原因如下: - 您可能不想将您的 redis 服务器暴露给互联网。- 就稳健性而言,客户端对闪存的数据检索依赖可能不是最佳解决方案。
I'd like to code this up someday and see how it performs. Let me know if you try it out!
我想有一天把它编码起来,看看它的表现如何。如果您尝试一下,请告诉我!

