4 "github.com/golang/groupcache/lru"
6 "github.com/vapor/federation/database/orm"
9 const maxAssetCached = 1024
11 type AssetCache struct {
15 func NewAssetCache() *AssetCache {
16 return &AssetCache{lruCache: lru.New(maxAssetCached)}
19 func (a *AssetCache) Add(assetID string, asset *orm.Asset) {
20 a.lruCache.Add(assetID, asset)
23 func (a *AssetCache) Get(assetID string) *orm.Asset {
24 if v, ok := a.lruCache.Get(assetID); ok {
31 func (a *AssetCache) Remove(assetID string) {
32 a.lruCache.Remove(assetID)