RejectedSoftware Forums

Sign up

Cannot get result from Redis blpop

I tried to use the blpop function on Redis.

auto message = m_db.blpop("test", 0L);

and the only response I have is "test".

The methode definition is

T blpop(T = string)(string key, long seconds) if(isValidRedisValueReturn!T) { return request!T("BLPOP", key, seconds); }
but according to Redis documentation BLPOP return an Array.

Return value
Array reply: specifically:
A nil multi-bulk when no element could be popped and the timeout expired.
A two-element multi-bulk with the first element being the name of the key where an element was popped and the second element being the value of the popped element.

Shouldn't blpop definition be something like this ?
RedisReply!T blpop(T = string)(string key, long seconds) if(isValidRedisValueReturn!T) { return request!T("BLPOP", key, seconds); }

Re: Cannot get result from Redis blpop

On Thu, 18 Feb 2016 18:27:11 GMT, Mickaël Bouchaud wrote:

I tried to use the blpop function on Redis.

auto message = m_db.blpop("test", 0L);

and the only response I have is "test".

The methode definition is

T blpop(T = string)(string key, long seconds) if(isValidRedisValueReturn!T) { return request!T("BLPOP", key, seconds); }
but according to Redis documentation BLPOP return an Array.

Return value
Array reply: specifically:
A nil multi-bulk when no element could be popped and the timeout expired.
A two-element multi-bulk with the first element being the name of the key where an element was popped and the second element being the value of the popped element.

Shouldn't blpop definition be something like this ?
RedisReply!T blpop(T = string)(string key, long seconds) if(isValidRedisValueReturn!T) { return request!T("BLPOP", key, seconds); }

Following the docs, it should ideally return something like Nullable!(Tuple!(string, T)). RedisReply!T wouldn't always work, because it would treat the first value (the key) as T instead of as string. I'll commit a fix.

Re: Cannot get result from Redis blpop

On Mon, 22 Feb 2016 11:43:17 GMT, Sönke Ludwig wrote:

On Thu, 18 Feb 2016 18:27:11 GMT, Mickaël Bouchaud wrote:

I tried to use the blpop function on Redis.

auto message = m_db.blpop("test", 0L);

and the only response I have is "test".

The methode definition is

T blpop(T = string)(string key, long seconds) if(isValidRedisValueReturn!T) { return request!T("BLPOP", key, seconds); }
but according to Redis documentation BLPOP return an Array.

Return value
Array reply: specifically:
A nil multi-bulk when no element could be popped and the timeout expired.
A two-element multi-bulk with the first element being the name of the key where an element was popped and the second element being the value of the popped element.

Shouldn't blpop definition be something like this ?
RedisReply!T blpop(T = string)(string key, long seconds) if(isValidRedisValueReturn!T) { return request!T("BLPOP", key, seconds); }

Following the docs, it should ideally return something like Nullable!(Tuple!(string, T)). RedisReply!T wouldn't always work, because it would treat the first value (the key) as T instead of as string. I'll commit a fix.

Implemented by 0e842e0 (plus compile error fixups).

Re: Cannot get result from Redis blpop

On Mon, 22 Feb 2016 17:23:01 GMT, Sönke Ludwig wrote:

On Mon, 22 Feb 2016 11:43:17 GMT, Sönke Ludwig wrote:

On Thu, 18 Feb 2016 18:27:11 GMT, Mickaël Bouchaud wrote:

I tried to use the blpop function on Redis.

auto message = m_db.blpop("test", 0L);

and the only response I have is "test".

The methode definition is

T blpop(T = string)(string key, long seconds) if(isValidRedisValueReturn!T) { return request!T("BLPOP", key, seconds); }
but according to Redis documentation BLPOP return an Array.

Return value
Array reply: specifically:
A nil multi-bulk when no element could be popped and the timeout expired.
A two-element multi-bulk with the first element being the name of the key where an element was popped and the second element being the value of the popped element.

Shouldn't blpop definition be something like this ?
RedisReply!T blpop(T = string)(string key, long seconds) if(isValidRedisValueReturn!T) { return request!T("BLPOP", key, seconds); }

Following the docs, it should ideally return something like Nullable!(Tuple!(string, T)). RedisReply!T wouldn't always work, because it would treat the first value (the key) as T instead of as string. I'll commit a fix.

Implemented by 0e842e0 (plus compile error fixups).

Thanks for the quick answer and fix I will try it today.

Re: Cannot get result from Redis blpop

Work great thanks !