lua-users home
lua-l archive

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


2011/3/24 Alexander Gladysh <agladysh@gmail.com>:
>>> 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).

To avoid clash with strings, you can have your status codes be
userdata without allocating one at each request. Just keep a redis.ok
value that you return, and client code can write "if status==redis.ok
then end".

That being said, I think (please correct me if I'm wrong) that string
allocation is not cheaper in terms of execution speed than userdata
allocation, unless most of the strings are expected to be already
interned (which completely depends on the data your client will put in
your redis db).