Redis understanding of outgoing types of LUA scripts

Source: Internet
Author: User

Lua to Redis conversion table.

    • Lua number, Redis integer reply (the number is converted to an integer)
    • Lua string--Redis bulk reply
    • Lua table (array), Redis Multi Bulk reply (truncated to the first nil inside the LUA array if any)
    • Lua table with a single ok field, Redis status reply
    • Lua table with a single err field, Redis error reply
    • Lua Boolean false, Redis Nil bulk reply.

It is also possible to summarize Redis's number,string, an array of table, Table.ok,table.err, from the type of Redis return.

Which means you want to.

return {name= "foo", passwd= "bar"} This is not possible.

That's why Redis has to put the Cjson,cmsgpack library in Lua, and you can only do that with complex types.

    • Lua table with a single ok field, Redis status reply
    • Lua table with a single err field, Redis error reply

For these two cases, I consider that it is not intended to use {ok= "OK"} {err= "Err"} in this form,

I'm more inclined to useredis.error_reply(error_string)和redis.status_reply(status_string).

Because this is more abstract, there will be fewer changes.

Redis understanding of outgoing types of LUA scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.