package genPool import ( "fmt" "github.com/goburrow/cache" ) var ( // 启服加载,不设置过期 // // 产出池道具缓存 key:genPoolID_itemID, value:GenPoolItem genPoolItemCache = cache.New( cache.WithMaximumSize(-1), ) ) func buildKey(genPoolID int32, itemID int32) string { return fmt.Sprintf("%d_%d", genPoolID, itemID) } func GetGenPoolItemCache(genPoolID int32, itemID int32) (*GenPoolItem, bool) { key := buildKey(genPoolID, itemID) if v, ok := genPoolItemCache.GetIfPresent(key); ok { return v.(*GenPoolItem), true } return nil, false } func SetGenPoolItemCache(genPoolItem *GenPoolItem) { key := buildKey(genPoolItem.GenPoolID, genPoolItem.ItemID) genPoolItemCache.Put(key, genPoolItem) }