[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Error handling strategy for Redis multi-bulk replies, in context of Lua bindings
- From: Alexander Gladysh <agladysh@...>
- Date: Thu, 24 Mar 2011 19:33:24 +0300
On Thu, Mar 24, 2011 at 14:52, Alexander Gladysh <agladysh@gmail.com> wrote:
> On Thu, Mar 24, 2011 at 05:52, Robert G. Jakabosky
> <bobby@sharedrealm.com> wrote:
>> On Wednesday 23, Alexander Gladysh wrote:
>>> MULTI
>>> SET a 3
>>> LPOP a
>>> INCR a
>>> EXEC
>>> Returns:
>>> 1. OK
>>> 2. (error) ERR Operation against a key holding the wrong kind of value
>>> 3. (integer) 4
>>> How should this result be returned to Lua?
>>> {
>>> "OK",
>>> -- how to express error message here?
>>> 4
>>> }
>>> P.S. Note that "OK" is a status reply (REDIS_REPLY_STATUS), not a
>>> string (REDIS_REPLY_STRING). I'd like to separate those two as well,
>>> but this is of much less priority (I think).
>> I would wrap status/error replies in a status userdata object with a is_error
>> field/method. For string/number reply values convert them to basic lua
>> string/numbers.
> Interesting idea. I'm trying to imagine how the user's code would look
> like. Wouldn't it be too cumbersome to work with?
Also, I'm concerned by the overhead — status replies are common in the
protocol, and creating an userdata per each can be too much (strings
should be cheaper, and, besides, users do not need to look into status
codes that often, I think).
Alexander.