func NewLRUBlockPool()

in lambda/internal/tarfile/s3file.go [261:278]


func NewLRUBlockPool(capacity int) *LRUBlockPool {
	pool := &sync.Pool{
		New: func() interface{} {
			return &Block{
				Id:  -1,
				Buf: make([]byte, iolimits.BlockSize),
			}
		},
	}
	cache := lru.New(capacity)
	cache.OnEvicted = func(k lru.Key, v interface{}) {
		pool.Put(v)
	}
	return &LRUBlockPool{
		pool:  pool,
		cache: cache,
	}
}