Blame view

src/services/redisd.lua 663 Bytes
314bc5df   zhengshouren   提交服务器初始代码
1
2
3
4
5
  local skynet = require "skynet"
  require "skynet.manager"
  local redis = require "skynet.db.redis"
  
  local db
3f604f2e   zhouhaihai   扩容 redis 和 log服务
6
  local idx = ...
314bc5df   zhengshouren   提交服务器初始代码
7
8
9
10
11
12
13
14
15
  local command = {}
  
  function command.open(conf)
  	db = redis.connect({
  		host = conf.redishost,
  		port = conf.redisport,
  		db = conf.redisdb or 0,
  		auth = conf.auth,
  	})
314bc5df   zhengshouren   提交服务器初始代码
16
17
18
19
20
21
22
23
24
25
26
  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)
7d31daa8   zhouhaihai   调整压测
27
  	skynet.info_func(function()
3b903aa0   zhouhaihai   队列长度
28
  		return skynet.stat("mqlen")
7d31daa8   zhouhaihai   调整压测
29
  	end)
3f604f2e   zhouhaihai   扩容 redis 和 log服务
30
  	skynet.register(".redis" .. idx)
314bc5df   zhengshouren   提交服务器初始代码
31
  end)