Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
ea86522c75
@ -124,3 +124,27 @@ func (this *configureComp) GetChannelRecordMax() (max int32, err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//获取手动加入频道 任务限制
|
||||
func (this *configureComp) GetChannelReadRecordNum() (max int32, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
configure *cfg.Game_chatChannelComData
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_chatChannelCom).GetDataMap()["load_chat"]; !ok {
|
||||
err = fmt.Errorf("cfg.Game_chatServerGroupData on found max_chat")
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
max = configure.Value
|
||||
if max <= 0 {
|
||||
err = fmt.Errorf("cfg.Game_chatChannelComData max_chat:%v", v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, group, ar
|
||||
c *mongo.Cursor
|
||||
n int
|
||||
max_chat int32
|
||||
readmax_chat int32
|
||||
)
|
||||
switch channel {
|
||||
case pb.ChatChannel_World:
|
||||
@ -90,7 +91,13 @@ func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, group, ar
|
||||
find = bson.M{"channel": channel}
|
||||
break
|
||||
}
|
||||
if cdata, err = this.Batchgetqueues(key); err == nil {
|
||||
if max_chat, err = this.module.configure.GetChannelRecordMax(); err != nil {
|
||||
return
|
||||
}
|
||||
if readmax_chat, err = this.module.configure.GetChannelReadRecordNum(); err != nil {
|
||||
return
|
||||
}
|
||||
if cdata, err = this.Batchgetqueues(key, readmax_chat); err == nil {
|
||||
result = make([]*pb.DBChat, len(cdata))
|
||||
for i, v := range cdata {
|
||||
chat := &pb.DBChat{}
|
||||
@ -100,7 +107,6 @@ func (this *modelChatComp) GetChatQueue(channel pb.ChatChannel, union, group, ar
|
||||
result[i] = chat
|
||||
}
|
||||
}
|
||||
max_chat, err = this.module.configure.GetChannelRecordMax()
|
||||
|
||||
if err == redis.RedisNil {
|
||||
//query from mgo
|
||||
|
@ -74,7 +74,8 @@ return "OK"
|
||||
//Redis 自定义脚本 批量读取队列数据
|
||||
var LuaScriptgetQueue = `
|
||||
local key = tostring(KEYS[1])
|
||||
local keys = redis.call("LRANGE", key,0,-1)
|
||||
local count = tonumber(ARGV[1]) * -1
|
||||
local keys = redis.call("LRANGE", key,count,-1)
|
||||
local data = {}
|
||||
for i, v in ipairs(keys) do
|
||||
data[i] = redis.call("HGETALL", v)
|
||||
@ -121,6 +122,7 @@ for i, v in ipairs(KEYS) do
|
||||
end
|
||||
redis.call("RPush", k,unpack(keys))
|
||||
local c = tonumber(redis.call("LLEN", k))
|
||||
count = count * 3
|
||||
if (c > count) then
|
||||
local off = c-count
|
||||
out = redis.call("LRANGE", k,0,off-1)
|
||||
@ -349,7 +351,7 @@ func (this *MCompModel) ChangeList(uid string, _id string, data map[string]inter
|
||||
}
|
||||
|
||||
//读取全部数据
|
||||
func (this *MCompModel) Get(uid string, data interface{}) (err error) {
|
||||
func (this *MCompModel) Get(uid string, data interface{}, opt ...DBOption) (err error) {
|
||||
if err = this.Redis.HGetAll(this.ukey(uid), data); err != nil && err != redis.RedisNil {
|
||||
return
|
||||
}
|
||||
@ -359,6 +361,10 @@ func (this *MCompModel) Get(uid string, data interface{}) (err error) {
|
||||
}
|
||||
err = this.Redis.HMSet(this.ukey(uid), data)
|
||||
}
|
||||
option := newDBOption(opt...)
|
||||
if option.Expire > 0 {
|
||||
this.Redis.Expire(this.ukey(uid), option.Expire)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -599,9 +605,9 @@ func (this *MCompModel) Batchsetlists(data map[string]map[string]string) (err er
|
||||
}
|
||||
|
||||
//批量读取队列数据
|
||||
func (this *MCompModel) Batchgetqueues(key string) (result []map[string]string, err error) {
|
||||
func (this *MCompModel) Batchgetqueues(key string, count int32) (result []map[string]string, err error) {
|
||||
var data interface{}
|
||||
ret := this.Redis.EvalSha(this.Redis.Context(), this.getQueueSha1, []string{key})
|
||||
ret := this.Redis.EvalSha(this.Redis.Context(), this.getQueueSha1, []string{key}, count)
|
||||
if data, err = ret.Result(); err != nil {
|
||||
fmt.Printf("Execute batchgetqueues err: %v", err.Error())
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user