谈一谈Redis的incr命令
大家讲道理
大家讲道理 2017-04-22 09:00:09
0
2
664

incr命令自动加一是只相对于这台机器而言还是相对于整个redis集群?
比如我一开始只有1台机器。有一个参数是count,这台机器的count达到了10000。
然后我增加了一台redis机器。
很显然,我的初衷是我再来取count的时候是从10000开始的。也就是说,整个变量对整个redis集群而言是唯一的。
此外,redis的主从同步大概要花多长时间?(就是立即同步那种,数据只存在内存中间)

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
左手右手慢动作

You need the machines in the cluster to maintain data consistency, provided there is a master-slave relationship.
If you perform an incr operation on a variable a on machine A to 10000, other machines will not update your value, unless your machine is the master in the cluster, and other machines are slaves of your machine. In this way, other machines will update their own a value to 10000;
The same goes for adding a machine. If the added machine is the slave of your machine, it will update the value of a. Start from 10000.

黄舟

Have you seen the implementation and configuration of redis cluster? Redis's own cluster implementation is for example three machines ABC. If there is key: "A_KEY" in A, then if you operate the cluster to get set, no matter which machine (ABC) you execute it on, you will get the key in A: "A_KEY" , so the answer to your question is no problem.

But you mentioned adding machines. The above answer is based on the assumption that you, as a user, have done everything correctly. To add machines, you will need to change the weight previously assigned to ABC3 machines to ABCD4 machines, so there are some Something to operate on.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template