1
This commit is contained in:
parent
74446ec857
commit
354154ce1b
20
server/marketserver/cache/cachemgr.go
vendored
20
server/marketserver/cache/cachemgr.go
vendored
@ -4,7 +4,6 @@ import (
|
|||||||
"q5"
|
"q5"
|
||||||
"f5"
|
"f5"
|
||||||
"mt"
|
"mt"
|
||||||
"fmt"
|
|
||||||
"main/common"
|
"main/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,13 +20,30 @@ func (this *cacheMgr) UnInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *cacheMgr) GetNfts(nfts []*common.NftDto) {
|
func (this *cacheMgr) GetNfts(nfts []*common.NftDto) {
|
||||||
|
{
|
||||||
|
nfts = []*common.NftDto{}
|
||||||
|
for _, val := range nfts {
|
||||||
|
this.fastGetNft(val)
|
||||||
|
if val.NftCache != nil {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, val := range nfts {
|
for _, val := range nfts {
|
||||||
this.internalGetNft(val)
|
this.internalGetNft(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *cacheMgr) fastGetNft(dto *common.NftDto) {
|
||||||
|
key := dto.GetKey()
|
||||||
|
if p, ok := this.nftHash.Load(key); ok {
|
||||||
|
dto.NftCache = *p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *cacheMgr) internalGetNft(dto *common.NftDto) {
|
func (this *cacheMgr) internalGetNft(dto *common.NftDto) {
|
||||||
key := fmt.Sprintf("%d_%s_%s", dto.NetId, dto.ContractAddress, dto.TokenId)
|
key := dto.GetKey()
|
||||||
if p, ok := this.nftHash.Load(key); ok {
|
if p, ok := this.nftHash.Load(key); ok {
|
||||||
dto.NftCache = *p
|
dto.NftCache = *p
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,6 +3,7 @@ package common
|
|||||||
import (
|
import (
|
||||||
"q5"
|
"q5"
|
||||||
"f5"
|
"f5"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NftHomeMeta struct {
|
type NftHomeMeta struct {
|
||||||
@ -86,7 +87,6 @@ type CacheMgr interface{
|
|||||||
GetNfts([]*NftDto)
|
GetNfts([]*NftDto)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this* StreamPagination) FillPage(page *f5.StreamPagination) {
|
func (this* StreamPagination) FillPage(page *f5.StreamPagination) {
|
||||||
if page.NextCursor != 0 {
|
if page.NextCursor != 0 {
|
||||||
this.NextCursor = q5.ToString(page.NextCursor)
|
this.NextCursor = q5.ToString(page.NextCursor)
|
||||||
@ -96,3 +96,8 @@ func (this* StreamPagination) FillPage(page *f5.StreamPagination) {
|
|||||||
}
|
}
|
||||||
this.Remaining = page.Remaining
|
this.Remaining = page.Remaining
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this* NftDto) GetKey() string {
|
||||||
|
key := fmt.Sprintf("%d_%s_%s", this.NetId, this.ContractAddress, this.TokenId)
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user