sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.64k stars 351 forks source link

[QUESTION]How can I create a `RedMutex` with RedisCluster? #490

Closed Mike4Feet closed 1 year ago

Mike4Feet commented 1 year ago

(First of all, I have a poor english.)

I found a example in README.md image

In this example, I can create a RedMutex with std::make_shared<Redis>. When I use w::redis::RedisCluster, How can I use RedMutex?

sewenew commented 1 year ago

redlock does not work with redis cluster. Instead, it works with one or more standalone redis. Please check redlock algorithm on redis official site for detail.

Regards


发件人: ZhiHan Li @.> 发送时间: Tuesday, May 30, 2023 5:24:27 PM 收件人: sewenew/redis-plus-plus @.> 抄送: Subscribed @.***> 主题: [sewenew/redis-plus-plus] [QUESTION]How can I create a RedMutex with RedisCluster? (Issue #490)

(First of all, I have a poor english.)

I found a example in README.md [image]https://user-images.githubusercontent.com/106004829/241913107-d4bb2dbe-4c51-4a26-a2eb-31733f1b66bc.png

In this example, I can create a RedMutex with std::make_shared. When I use w::redis::RedisCluster, How can I use RedMutex?

― Reply to this email directly, view it on GitHubhttps://github.com/sewenew/redis-plus-plus/issues/490, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACWWTAL3L3BUCKFI7RB4VX3XIW4EXANCNFSM6AAAAAAYTXC64U. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Mike4Feet commented 1 year ago

redlock does not work with redis cluster. Instead, it works with one or more standalone redis. Please check redlock algorithm on redis official site for detail. Regards ____ 发件人: ZhiHan Li @.> 发送时间: Tuesday, May 30, 2023 5:24:27 PM 收件人: sewenew/redis-plus-plus @.> 抄送: Subscribed @.> 主题: [sewenew/redis-plus-plus] [QUESTION]How can I create a RedMutex with RedisCluster? (Issue #490) (First of all, I have a poor english.) I found a example in README.md [image]https://user-images.githubusercontent.com/106004829/241913107-d4bb2dbe-4c51-4a26-a2eb-31733f1b66bc.png In this example, I can create a RedMutex with std::make_shared. When I use w::redis::RedisCluster, How can I use RedMutex? ― Reply to this email directly, view it on GitHub<#490>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACWWTAL3L3BUCKFI7RB4VX3XIW4EXANCNFSM6AAAAAAYTXC64U. You are receiving this because you are subscribed to this thread.Message ID: @.>

Does it mean, when I wanna use redlock with redis cluster, the master and slaves can be recognized as standalone redis? For example, the redis cluster is "redis://:pass@192.168.2.11:6379,192.168.2.12:6379,192.168.2.13:6379,192.168.2.14:6379/0?PoolSize=10", is the following code correct ? image

sewenew commented 1 year ago

NO. You should NOT use redlock with Redis Cluster. Instead, you need to deploy multiple standalone Redis master instances.

The sync mechanism between master node and slave node will break redlock algorithm.

Regards

sewenew commented 1 year ago

Since there's no update, I'll close the issue. If you still have problem with RedLock, free feel to reopen it.

Regards