UpdateChannelDocument 제거

This commit is contained in:
2023-08-14 14:44:56 +09:00
parent a08353a920
commit 884fb0080f
5 changed files with 81 additions and 135 deletions

View File

@ -245,28 +245,24 @@ func (sub *subTavern) OnClientMessageReceived(sender *wshandler.Sender, messageT
}
func (sub *subTavern) OnRoomCreated(region, name string) {
created, err := sub.redison.JSONSet(name, "$", map[string]any{
"_refcnt": 1,
}, gocommon.RedisonSetOptionNX)
cnt, err := sub.redison.IncrBy(sub.redison.Context(), "_ref_"+name, 1).Result()
if err != nil && !errors.Is(err, redis.Nil) {
logger.Println("OnRoomCreated JSONSet failed :", err)
return
}
if !created {
_, err = sub.redison.JSONNumIncrBy(name, "$._refcnt", 1)
if err != nil {
logger.Println("OnRoomCreated JSONSet failed :", err)
return
}
if cnt == 1 {
sub.redison.JSONSet(name, "$", map[string]any{})
}
}
func (sub *subTavern) OnRoomDestroyed(region, name string) {
cnt, err := sub.redison.JSONNumIncrBy(name, "$._refcnt", -1)
if err != nil || len(cnt) == 0 {
cnt, err := sub.redison.IncrBy(sub.redison.Context(), "_ref_"+name, -1).Result()
if err != nil {
logger.Println("OnRoomDestroyed JSONNumIncrBy failed :", err)
} else if cnt[0] == 0 {
sub.redison.Del(sub.redison.Context(), name)
} else if cnt == 0 {
sub.redison.Del(sub.redison.Context(), "_ref_"+name)
sub.redison.JSONDel(name, "$")
}
}