Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key prefixing with blpop returns prefixed key #325

Closed
Tomino2112 opened this issue Jun 9, 2016 · 5 comments
Closed

Key prefixing with blpop returns prefixed key #325

Tomino2112 opened this issue Jun 9, 2016 · 5 comments

Comments

@Tomino2112
Copy link

When you use the keyPrefix option you should be getting back the "un-prefixed" version of the key when using multiple keys in blpop.

Example:

redis = new Redis({keyPrefix: "test:"})

var actionOneKey = "case:1",
    actionTwoKey = "case:2";

redis.blpop([actionOneKey, actionTwoKey], 0, function(err, msg){
    console.log(msg[0]); // Is "test:case:1", but really should be "case:1"

    // Fails
    if (msg[0] === actionOneKey){}
});

redis.lpush("test:case:1", "Hello World");
@luin
Copy link
Collaborator

luin commented Jun 9, 2016

keyPrefix is only applied to the keys when sending commands to Redis. It has no intention to be a total solution as a namespaces to allow multiple applications sharing a single Redis server.

It's pretty similar to another issue #239.

@Tomino2112
Copy link
Author

It is not really about multiple applications, its more about being able to programatically use set of keys and handle them without having to hard code them at any point.

@luin
Copy link
Collaborator

luin commented Jun 9, 2016

@Tomino2112 Yeah, I know there are some use cases where the support for namespace become very useful. However it's a little difficult to implement that.

The support for keyPrefix option is achieved with the benefit of the Redis command API so we could be able to know which arguments of a command are keys. However, there's no such API for replies, which means we have to hardcode a list recording which replies should be transformed. This way is far from reliable IMO and requires a lot of work.

@Tomino2112
Copy link
Author

I think I understand, Its no problem to just not use it. THanks

@luin
Copy link
Collaborator

luin commented Jun 9, 2016

I just added a link to this issue to the README. Thank you for pointing this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants