[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Error handling strategy for Redis multi-bulk replies, in context of Lua bindings
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Thu, 24 Mar 2011 17:57:26 +0100
2011/3/24 Alexander Gladysh <firstname.lastname@example.org>:
>>> 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
>> 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
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).