lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, Mar 24, 2011 at 14:52, Alexander Gladysh <> wrote:
> On Thu, Mar 24, 2011 at 05:52, Robert G. Jakabosky
> <> wrote:
>> On Wednesday 23, Alexander Gladysh wrote:

>>> 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).