redisd.lua
763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local skynet = require "skynet"
require "skynet.manager"
local redis = require "skynet.db.redis"
local db
local command = {}
function command.open(conf)
db = redis.connect({
host = conf.redishost,
port = conf.redisport,
db = conf.redisdb or 0,
auth = conf.auth,
})
--[[
local csvdata = require("csvdata.world_boss_battle")
for i=1, #csvdata do
for j=1, #csvdata[i] do
db:del(string.format("boss:%d:%d", i, j))
end
end
--]]
db:del("rtpvp")
end
skynet.start(function()
skynet.dispatch("lua", function(session, address, cmd, ...)
if cmd == "open" then
local f = command[string.lower(cmd)]
skynet.ret(skynet.pack(f(...)))
else
skynet.ret(skynet.pack(db[string.lower(cmd)](db, ...)))
end
end)
skynet.register "REDIS"
end)