What would it take to implement a good redis-client in the web-browser?

无人久伴 提交于 2019-12-07 06:42:52

问题


This has been asked before at Can I connect directly to a Redis server from JavaScript running in a browser? (notice my comment) and Connecting directly to Redis with (client side) javascript? but I wonder about something which would have perfect realtime connection. Reading the (a node-redis client) https://github.com/luin/ioredis source I noticed the net part of node`s library is likely containing the kind of functionality we'd need to reproduce in the browser to do this .

Guessing maybe something with hacked together from pieces of webrtc functions could do it ?

Prospective benefits relate to building large distributed app systems infrastructure -- like social media (from comment on first question linked above):

I'm asking this question again, but stipulating we want a 'real' as in realtime redis-client -- not HTTP anything -- operating in the browser. Could build a great realtime 'infrastructure' with just CDN serving assets constituting the client webapp communicating with Redis directly. I want to cut out the unnecessary WebSocket server aspect of the system. All the control logic can be internalised to redis cluster in Lua.


回答1:


To implement a direct redis-client in the web-browser you need to change Redis itself, so it will expose WebSocket interface. That way you will get the simplest protocol browser is allowed to use.

Other approaches will involve intermediate layers. I think it should be possible to proxy commands via ws-tcp-relay which is pretty fast.



来源:https://stackoverflow.com/questions/33241247/what-would-it-take-to-implement-a-good-redis-client-in-the-web-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!