mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 03:53:09 +00:00
simple rpc support
This commit is contained in:
22
simpledb.lua
Normal file
22
simpledb.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
local skynet = require "skynet"
|
||||
local db = {}
|
||||
|
||||
local command = {}
|
||||
|
||||
function command.GET(key)
|
||||
skynet.ret(db[key])
|
||||
end
|
||||
|
||||
function command.SET(key, value)
|
||||
local last = db[key]
|
||||
db[key] = value
|
||||
skynet.ret(last)
|
||||
end
|
||||
|
||||
skynet.dispatch(function(message, from, session)
|
||||
print("simpledb",message, from, session)
|
||||
local cmd, key , value = string.match(message, "(%w+) (%w+) ?(.*)")
|
||||
command[cmd](key,value)
|
||||
end)
|
||||
|
||||
skynet.register "SIMPLEDB"
|
||||
Reference in New Issue
Block a user