ssdb-rocks icon indicating copy to clipboard operation
ssdb-rocks copied to clipboard

why use lua set value is much slower than php?

Open javacty opened this issue 9 years ago • 0 comments

lua: location /ssdb1 { default_type 'text/plain'; content_by_lua ' local ssdb = require "resty.ssdb" local db = ssdb:new()

            db:set_timeout(1000) -- 1 sec

            local ok, err = db:connect("127.0.0.1", 8888)
            if not ok then
                ngx.say("failed to connect: ", err)
                return
            end                

            for i=1,100000,1
            do
                db:init_pipeline()
                db:set("key"..tostring(i), i)
                local results, err = db:commit_pipeline()
            end
        ';

} spend about 42 seconds

php:

pconnect('127.0.0.1', 8888); $time_start = microtime_float(); //保存数据 for($i = 0; $i sadd("key$i",$i); } spend about 24 seconds

javacty avatar May 17 '15 07:05 javacty