LUA splits strings according to special characters; Hmget using Redis

Source: Internet
Author: User
Tags lua redis

The recent talk project used part of Lua, which was used to request very high requests, to block back at the nginx level, and to invoke a large number of PHP processes in the province.
Since LUA has not been used before, the development process has encountered a number of small skill points, recorded.

1.lua string Split function

The code is as follows Copy Code
Example
--string partition function, split by |
function Lua_string_split (str, Split_char)
Local sub_str_tab = {};
For mu_id in String.gmatch (str, "(%d+) |*") do
Table.insert (Sub_str_tab, mu_id)
End
return sub_str_tab;
End
--string Split function end

2. Use Lua's Reids batch acquisition method. For example: Hmget
First, integrate all the field into a table, such as: Field_table.

Example

The code is as follows Copy Code

Redis:hmget (Key, Unpack (field_table))

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.