🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## eval ##### Description Evaluate a LUA script serverside 在服务器端执行LUA脚本 ##### Parameters *script* string. *args* array, optional. *num\_keys* int, optional. ##### Return value Mixed. What is returned depends on what the LUA script itself returns, which could be a scalar value (int/string), or an array. Arrays that are returned can also contain other arrays, if that's how it was set up in your LUA script. If there is an error executing the LUA script, the getLastError() function can tell you the message that came back from Redis (e.g. compile error). 这个函数返回的结果是函数传输的LUA脚本的执行结果。结果可以是一个普通的数据类型,也可以使一个数组,数组内也可以嵌套数组。无论返回的结果是什么,都是取决于你的LUA脚本是如何执行的。如果你传输的LUA脚本存在错误,那么getLastError()能够返回出REDIS对于这个错误的具体消息。 ##### Examples ``` <pre class="calibre16">$redis->eval("return 1"); // Returns an integer: 1 $redis->eval("return {1,2,3}"); // Returns Array(1,2,3) $redis->del('mylist'); $redis->rpush('mylist','a'); $redis->rpush('mylist','b'); $redis->rpush('mylist','c'); // Nested response: Array(1,2,3,Array('a','b','c')); $redis->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}}"); ``` ##