// It is ideal to configure a single instance of DefaultRedisScript in your application context to avoid re-calculation of the script’s SHA1 on every script run.
Stringscript=""+"local keys,values = KEYS,ARGV "+"local result = {s='ss'}; "+"for i, v in ipairs(keys) do "+" local stock = tonumber(redis.call('GET', v));"+" local num = tonumber(values[i]);"+" if (stock >= num) then"+" result[v]=redis.call('incrby', v, 0 - num);"+" else "+" result[v]=-1;"+" end "+"end "+"redis.log(redis.LOG_NOTICE,'hello world') "+"for k,v in pairs(result) do\n"+" redis.log(redis.LOG_NOTICE, k,result[k]) "+"end "+"return cjson.encode(result);";