This commit is contained in:
aozhiwei 2024-06-16 14:19:59 +08:00
parent 8b75a36150
commit e109c6fbe6
3 changed files with 5 additions and 6 deletions

View File

@ -4,13 +4,12 @@ import (
"q5"
"f5"
"mt"
"sync"
"fmt"
"main/common"
)
type cacheMgr struct {
nftHash sync.Map //net_id contract_address token_id -> nft
nftHash *q5.ConcurrentMap[string, *nft] //net_id contract_address token_id -> nft
}
func (this *cacheMgr) Init() {
@ -30,12 +29,12 @@ func (this *cacheMgr) GetNfts(nfts []*common.NftDto) {
func (this *cacheMgr) internalGetNft(dto *common.NftDto) {
key := fmt.Sprintf("%d_%s_%s", dto.NetId, dto.ContractAddress, dto.TokenId)
if p, ok := this.nftHash.Load(key); ok {
dto.NftCache = p.(*nft)
dto.NftCache = *p
} else {
l := f5.AllocLock(key)
defer f5.ReleaseLock(l)
if p, ok := this.nftHash.Load(key); ok {
dto.NftCache = p.(*nft)
dto.NftCache = *p
} else {
f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php",

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit ee715d672d83932a6a20f810cc490d737fad01e6
Subproject commit 550a64387e2d163b99ea39bbf48500bba998676e

2
third_party/q5 vendored

@ -1 +1 @@
Subproject commit 9048589a4ddb6d7432350a2030f8445b9fac7d83
Subproject commit 47f75d8247df848d50ba0e763c41dd6554a8b758