mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 19:13:07 +00:00
28 lines
539 B
Lua
28 lines
539 B
Lua
local skynet = require "skynet"
|
|
require "skynet.manager" -- import skynet.register
|
|
local db = {}
|
|
|
|
local command = {}
|
|
|
|
function command.GET(key)
|
|
return db[key]
|
|
end
|
|
|
|
function command.SET(key, value)
|
|
local last = db[key]
|
|
db[key] = value
|
|
return last
|
|
end
|
|
|
|
skynet.start(function()
|
|
skynet.dispatch("lua", function(session, address, cmd, ...)
|
|
local f = command[string.upper(cmd)]
|
|
if f then
|
|
skynet.ret(skynet.pack(f(...)))
|
|
else
|
|
error(string.format("Unknown command %s", tostring(cmd)))
|
|
end
|
|
end)
|
|
skynet.register "SIMPLEDB"
|
|
end)
|