1

I am trying to get values by keys array from redis cluster in nodejs, and it returns error: "All keys in the pipeline should belong to the same slot" this is code:

    private GETALL_P(keys: string[], cb: any) {

    var pipeline = this.client.pipeline();

    keys.forEach(function (key: string, index: Number) {
        pipeline.get(key);
    });

    pipeline.exec(function (err: any, result: any) {
        cb(err, result);
    });
}

I searched and someone said: it is not working with cluster. Is there any way to do this?

1 Answer 1

1

Multi key operations on a redis cluster need to be on the same node, which is what the error is complaining about.

To force all the required keys to the same node you can use key hash tags, just bear in mind that if you are doing this for all keys and not just some subset then you're making the use of a cluster fairly pointless.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for response. Problem is that data already is saved in redis by different service. I only read that data.
Do you have to use a pipeline? Non-pipelined should work fine, it'll just be slower.
yes that error happens when i use pipeline, but non-pipelined throws this error "ERR EXEC without MULTI" . --> redis.multi({ pipeline: false });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.