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"
|
||||
"f5"
|
||||
"mt"
|
||||
"fmt"
|
||||
"main/common"
|
||||
)
|
||||
|
||||
@ -21,13 +20,30 @@ func (this *cacheMgr) UnInit() {
|
||||
}
|
||||
|
||||
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 {
|
||||
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) {
|
||||
key := fmt.Sprintf("%d_%s_%s", dto.NetId, dto.ContractAddress, dto.TokenId)
|
||||
key := dto.GetKey()
|
||||
if p, ok := this.nftHash.Load(key); ok {
|
||||
dto.NftCache = *p
|
||||
} else {
|
||||
|
@ -3,6 +3,7 @@ package common
|
||||
import (
|
||||
"q5"
|
||||
"f5"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type NftHomeMeta struct {
|
||||
@ -86,7 +87,6 @@ type CacheMgr interface{
|
||||
GetNfts([]*NftDto)
|
||||
}
|
||||
|
||||
|
||||
func (this* StreamPagination) FillPage(page *f5.StreamPagination) {
|
||||
if page.NextCursor != 0 {
|
||||
this.NextCursor = q5.ToString(page.NextCursor)
|
||||
@ -96,3 +96,8 @@ func (this* StreamPagination) FillPage(page *f5.StreamPagination) {
|
||||
}
|
||||
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