// Create a cache whose information expires with the supplied TTL. If the TTL // is zero, nothing will ever be cached. func newTypeCache( perTypeCapacity int, ttl time.Duration) (tc typeCache) { tc = typeCache{ ttl: ttl, files: lrucache.New(perTypeCapacity), dirs: lrucache.New(perTypeCapacity), } return }
// Create a new stat cache that holds the given number of entries, which must // be positive. func NewStatCache(capacity int) (sc StatCache) { sc = &statCache{ c: lrucache.New(capacity), } return }
// Create a cache that holds the given number of items, evicting the least // recently used item when more space is needed. func NewLruCache(capacity uint) Cache { c := &lruCache{ wrapped: lrucache.New(int(capacity)), } c.mu = syncutil.NewInvariantMutex(c.wrapped.CheckInvariants) return c }
func (t *CacheTest) SetUp(ti *TestInfo) { t.cache.Wrapped = lrucache.New(capacity) }