简体   繁体   English

RoR + Redis Master-从站

[英]RoR + Redis Master - Slaves

im hacking an app using RoR and Redis. 我使用RoR和Redis入侵了应用。

The Redis infrastructure wil have one master ( Writer ) and 3 slaves ( Readers ) and using HAProxy as load balancer to the Slaves. Redis基础结构将有一个主服务器(Writer)和三个从服务器(Readers),并使用HAProxy作为从站的负载平衡器。

What approach , you guys, are using in this scenario? 你们在这种情况下使用什么方法?

Should I have two Redis Client , one to MASTER and other to SLAVE (load balancer) ? 我是否应该有两个Redis Client,一个用于MASTER,另一个用于SLAVE(负载均衡器)?

what is the best approach ? 最好的方法是什么?

Thanks 谢谢

I would recommend using a wrapper on top of the redis connection. 我建议在redis连接的顶部使用包装器。 This way you can transparently implement the logic for implement writer/reader and use any scenario you want (this could be environment specific). 这样,您可以透明地实现用于实现编写器/读取器的逻辑,并使用所需的任何方案(这可能是特定于环境的)。

This way you can either call it direcly 这样您可以直接调用它

RedisWrapper.hget(key, field)

or build a layer on top of it (think something like remodel ). 或在其之上构建一个层(例如remodel东西)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM