// newTimedcache creates a new timedCache.
175335
func newTimedcache(ttl time.Duration, getter getFunc) (*timedCache, error) {
	if getter == nil {
		return nil, fmt.Errorf("getter is not provided")
	}

	return &timedCache{
		getter: getter,
		store:  cache.NewTTLStore(cacheKeyFunc, ttl),
	}, nil
}
1251763
func NewTemplateEngine(root string) *TemplateEngine {
	return &TemplateEngine{
		cache:           map[string]*template.Template{},
		templWithLayout: map[string][]string{},
		root:            root,
	}
}
28021
func (c *ConfigLocal) KeyBundleCache() kbfsmd.KeyBundleCache {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.kbcache
}
925126
func NewExpireCache(ttl time.Duration) *ExpireCache {
	return &ExpireCache{
		cache: make(map[interface{}]*expireRecord),
		ttl:   ttl,
	}
}
730934
func NewTimeSpanFilter(start, stop time.Time) Filter {
	return &filter{filterType: timeSpanFilter, value: timeZone{start: start, stop: stop}}
}
1367806
func NewTimeWaitGen(steps int, ms time.Duration, init func(WaitInterface)) *WaitGen {
	return &WaitGen{
		nil,
		func() WaitInterface {
			nt := NewTimeWait(steps, ms)
			init(nt)
			return nt
		},
	}
}
1273613
func NewMemcache(server ...string) *Memcache {
	mc := memcache.New(server...)
	return &Memcache{mc}
}
1000616
func (c *ConfigLocal) DiskMDCache() DiskMDCache {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.diskMDCache
}
5583
func NewTimer(interval time.Duration) *Timer {
	tm := &Timer{
		msg: make(chan typeAction),
	}
	tm.interval.Set(interval)
	return tm
}
508964
func NewTTLStore(keyFunc KeyFunc, ttl time.Duration) Store {
	return &ExpirationCache{
		cacheStorage:     NewThreadSafeStore(Indexers{}, Indices{}),
		keyFunc:          keyFunc,
		clock:            util.RealClock{},
		expirationPolicy: &TTLPolicy{ttl, util.RealClock{}},
	}
}
1066333
func (c *Context) NewTempDir(prefix string) (string, error) {
	t, err := ioutil.TempDir(c.Tmpdir, prefix)
	if err != nil {
		return "", fmt.Errorf("error creating temporary directory: %v", err)
	}
	return t, nil
}
779996
func NewCache(maxSize uint64) *Cache {
	c := &Cache{
		maxSize:      maxSize,
		store:        emptyStore{},
		lastSnapshot: time.Now(),
		tracker:      newCacheTracker(newCacheMetrics(nil), nil),
	}
	c.initialize.Store(&sync.Once{})
	return c
}
385323
func (c *ConfigLocal) BlockCache() data.BlockCache {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.bcache
}
637402
func (fs *cachingFS) SetMtime(mtime time.Time) {
	fs.mu.Lock()
	defer fs.mu.Unlock()

	fs.mtime = mtime
}
671184
func NewTimeData() TimeData {
	now := w.Now()
	return TimeData{
		CreationTime:         &now,
		LastModificationTime: &now,
		LastAccessTime:       &now,
		LocationChanged:      &now,
		Expires:              false,
		UsageCount:           0,
	}
}
531098
func NewKeyCacheMeasured(delegate KeyCache, r metrics.Registry) KeyCacheMeasured {
	getTimer := metrics.GetOrRegisterTimer("KeyCache.GetTLFCryptKey", r)
	putTimer := metrics.GetOrRegisterTimer("KeyCache.PutTLFCryptKey", r)
	// TODO: Implement RatioGauge (
	// http://metrics.dropwizard.io/3.1.0/manual/core/#ratio-gauges
	// ) so we can actually display a hit ratio.
	hitCountMeter := metrics.GetOrRegisterMeter("KeyCache.HitCount", r)
	return KeyCacheMeasured{
		delegate:      delegate,
		getTimer:      getTimer,
		putTimer:      putTimer,
		hitCountMeter: hitCountMeter,
	}
}
387400
func (ss *scaleSet) newVmssCache() (*timedCache, error) {
	getter := func(key string) (interface{}, error) {
		ctx, cancel := getContextWithCancel()
		defer cancel()
		result, err := ss.VirtualMachineScaleSetsClient.Get(ctx, ss.ResourceGroup, key)
		exists, message, realErr := checkResourceExistsFromError(err)
		if realErr != nil {
			return nil, realErr
		}

		if !exists {
			klog.V(2).Infof("Virtual machine scale set %q not found with message: %q", key, message)
			return nil, nil
		}

		return &result, nil
	}

	return newTimedcache(vmssCacheTTL, getter)
}