diff --git a/server/marketserver/cache/cachemgr.go b/server/marketserver/cache/cachemgr.go index af8767dc..1162eeb1 100644 --- a/server/marketserver/cache/cachemgr.go +++ b/server/marketserver/cache/cachemgr.go @@ -47,31 +47,37 @@ func (this *cacheMgr) fastGetNft(dto *common.NftDto) { func (this *cacheMgr) internalGetNft(dto *common.NftDto) { key := dto.GetKey() + if p, ok := this.nftHash.Load(key); ok { + if q5.GetTickCount() - (*p).refreshTick < 1000 * 15 { + dto.NftCache = *p + return + } + this.nftHash.Delete(key) + if !f5.IsOnlineEnv() { + f5.GetSysLog().Warning("remove cache %s", dto.TokenId) + } + } + l := f5.AllocLock(key) + defer f5.ReleaseLock(l) if p, ok := this.nftHash.Load(key); ok { dto.NftCache = *p } else { - l := f5.AllocLock(key) - defer f5.ReleaseLock(l) - if p, ok := this.nftHash.Load(key); ok { - dto.NftCache = *p - } else { - f5.GetHttpCliMgr().SendGoStyleRequest( - mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", - map[string]string{ - "c": "OutAppNft", - "a": "nftDetailByContractAddress", - "contract_address": dto.ContractAddress, - "net_id": q5.ToString(dto.NetId), - "token_id": dto.TokenId, - }, - func (rsp f5.HttpCliResponse) { - if rsp.GetErr() == nil { - jsonRsp := map[string]interface{}{} - q5.DecodeJson(rsp.GetRawData(), &jsonRsp) - dto.NftCache = this.addNft(dto.NetId, dto.ContractAddress, dto.TokenId, jsonRsp) - } - }) - } + f5.GetHttpCliMgr().SendGoStyleRequest( + mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", + map[string]string{ + "c": "OutAppNft", + "a": "nftDetailByContractAddress", + "contract_address": dto.ContractAddress, + "net_id": q5.ToString(dto.NetId), + "token_id": dto.TokenId, + }, + func (rsp f5.HttpCliResponse) { + if rsp.GetErr() == nil { + jsonRsp := map[string]interface{}{} + q5.DecodeJson(rsp.GetRawData(), &jsonRsp) + dto.NftCache = this.addNft(dto.NetId, dto.ContractAddress, dto.TokenId, jsonRsp) + } + }) } }