LUA data conversion problem:
All data types in LUA will be internally converted into double types. If you need to display a double type, you can do this:
LUA:
local num=3.14;
printf(totring num)。
when Lua executes the Redis command through the call or pcall function, the return value of the command will be converted into Lua data structure. Similarly, when Lua script runs in the interpreter built in Redis, the return value of Lua script will also be converted into Redis protocol, and then the value will be returned to the client by EVAL.
the conversion between data types follows a design principle: if a Redis value is converted into a Lua value, and then the converted Lua value is converted back to a Redis value, then the Redis value obtained from this conversion should be the same as the original Redis value.
in other words, there is a one-to-one conversion relationship between Lua type and Redis type.
there is no difference between integers and floating-point numbers in p>lua. Therefore, we always convert Lua's number into an integer reply, which will discard the decimal part. If you want to return a floating-point number from Lua, you should use it as a string (see, for example, the ZSCORE command).
There is no simple way to have nils inside Lua arrays, this is a result of Lua table semantics, So when redisconverters a Lua array into redisprotocols the conversion is stopped if a Nile is encountered.
Lua is a dynamically typed language, so variables have no types, only values have types. Values can be stored in variables, passed as parameters, and returned as results.
although there is no data type of variable in Lua, there is a value of type.