From d706ab1384b3b49195687130601c81582174f2c3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 29 Jun 2024 14:27:04 +0800 Subject: [PATCH] 1 --- server/marketserver/cache/cachemgr.go | 50 +++++++++++++++------------ 1 file changed, 28 insertions(+), 22 deletions(-) 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) + } + }) } }