You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
fix bug in cluster slots, enhance live resharding test
This commit is contained in:
1
index.ts
1
index.ts
@@ -19,4 +19,3 @@ export function createClient<S extends RedisScripts = Record<string, never>>(
|
|||||||
modules
|
modules
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -82,7 +82,7 @@ export default class RedisClusterSlots<M extends RedisModules, S extends RedisSc
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const { from, to } of master.slots) {
|
for (const { from, to } of master.slots) {
|
||||||
for (let i = from; i < to; i++) {
|
for (let i = from; i <= to; i++) {
|
||||||
this.#slots[i] = slot;
|
this.#slots[i] = slot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -82,6 +82,12 @@ describe('Cluster', () => {
|
|||||||
10
|
10
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
cluster.getMasters().map(({ client }) => {
|
||||||
|
return client.clusterSetSlot(slot, ClusterSlotStates.NODE, to!.id);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
// should be able to get the key from the new node
|
// should be able to get the key from the new node
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.get(key),
|
await cluster.get(key),
|
||||||
|
Reference in New Issue
Block a user