Key prefixing with blpop returns prefixed key
Tomino2112 opened this issue · 5 comments
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");
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.
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.
@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.
I think I understand, Its no problem to just not use it. THanks
I just added a link to this issue to the README. Thank you for pointing this out!