save
This commit is contained in:
parent
ba7a99d362
commit
b0f7b10a02
@ -85,7 +85,7 @@ func (m *Mail) IsReadableMail(accountObj common.Player) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nowUnixSec := int32(time.Now().Unix())
|
nowUnixSec := int32(time.Now().Unix())
|
||||||
if m.ExpireTime > nowUnixSec && m.SendTime <= nowUnixSec && !accountObj.IsDeletedMail(m.MailId) {
|
if m.ExpireTime > nowUnixSec && m.SendTime <= nowUnixSec && accountObj.IsUnreadMail(m.MailId) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,6 @@ func (mm *MailMgr) GetMails(player common.Player) []*Mail {
|
|||||||
resMailList = append(resMailList, pMail)
|
resMailList = append(resMailList, pMail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resMailList
|
return resMailList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ func (p *Player) GetRegisterTime() int32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) IsUnreadMail(mailId int64) bool {
|
func (p *Player) IsUnreadMail(mailId int64) bool {
|
||||||
m := p.ReadMailHash[mailId]
|
_, exists := p.ReadMailHash[mailId]
|
||||||
return m == nil
|
return !exists
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) IsDeletedMail(mailId int64) bool {
|
func (p *Player) IsDeletedMail(mailId int64) bool {
|
||||||
@ -72,7 +72,6 @@ func (p *Player) MarkMail(mailIds string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.MarkDirty()
|
p.MarkDirty()
|
||||||
// p.SaveToDB()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) DeleteMails(mailIds string) {
|
func (p *Player) DeleteMails(mailIds string) {
|
||||||
@ -186,7 +185,7 @@ func (p *Player) Serialize(accountPB *ss.MFAccountData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) UpdateExpire() {
|
func (p *Player) UpdateExpire() {
|
||||||
p.CacheExpiration = time.Now().Add(10 * time.Second)
|
p.CacheExpiration = time.Now().Add(20 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) IsCacheExpired() bool {
|
func (p *Player) IsCacheExpired() bool {
|
||||||
@ -216,6 +215,8 @@ func (p *Player) SaveToDB() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
f5.GetSysLog().Info("SaveToDB Error:%v\n", err)
|
f5.GetSysLog().Info("SaveToDB Error:%v\n", err)
|
||||||
} else {
|
} else {
|
||||||
|
// 标记p 为已过期
|
||||||
|
p.CacheExpiration = time.Now().Add(-10 * time.Second)
|
||||||
f5.GetSysLog().Info("SaveToDB OK\n")
|
f5.GetSysLog().Info("SaveToDB OK\n")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package player
|
package player
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"f5"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ func (pm *PlayerMgr) GetPlayer(accountId string) *Player {
|
|||||||
func (pm *PlayerMgr) AsyncGetPlayer(accountId string) *Player {
|
func (pm *PlayerMgr) AsyncGetPlayer(accountId string) *Player {
|
||||||
p := pm.GetPlayer(accountId)
|
p := pm.GetPlayer(accountId)
|
||||||
if p != nil && !p.IsCacheExpired() {
|
if p != nil && !p.IsCacheExpired() {
|
||||||
|
f5.GetSysLog().Info("GetPlayer(%s) from cache", accountId)
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ func (pm *PlayerMgr) AsyncGetPlayer(accountId string) *Player {
|
|||||||
go func(accountId string) {
|
go func(accountId string) {
|
||||||
pm.LoadPlayer(accountId, func(err error, p *Player) {
|
pm.LoadPlayer(accountId, func(err error, p *Player) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err != nil && p != nil {
|
if err == nil && p != nil {
|
||||||
player = p
|
player = p
|
||||||
pm.accountIdHash[p.GetAccountId()] = p
|
pm.accountIdHash[p.GetAccountId()] = p
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user