// NewCache creates a new Cache based on FileSystem fs.
// fs.Files() are loaded using the name they were created with as a key.
// Reaper is used to determine when files expire, nil means never expire.
765628
func NewCache(fs FileSystem, grim Reaper) (Cache, error) {
	if grim != nil {
		return NewCacheWithHaunter(fs, NewReaperHaunterStrategy(grim))
	}

	return NewCacheWithHaunter(fs, nil)
}
164839
func NewCacheConfig() CacheConfig {
	return CacheConfig{
		MaxMemorySize:             DefaultCacheMaxMemorySize,
		SnapshotMemorySize:        DefaultCacheSnapshotMemorySize,
		SnapshotAgeDuration:       DefaultCacheSnapshotAgeDuration,
		SnapshotWriteColdDuration: DefaultCacheSnapshotWriteColdDuration,
	}
}
960351
func NewCacher(name string, opt Options) (Cache, error) {
	adapter, ok := adapters[name]
	if !ok {
		return nil, fmt.Errorf("cache: unknown adapter '%s'(forgot to import?)", name)
	}
	return adapter, adapter.StartAndGC(opt)
}
1361422
func NewCacheWithExpirationNotifier(name string, lifetime time.Duration, expirer ExpirationNotifier) *Cache {

	c := &Cache{
		name:     name,
		data:     make(map[interface{}]entry),
		lifetime: lifetime,
		expirer:  expirer,
	}
	c.max = len(c.data)
	registry.Add(c)
	return c
}
65098
func New(store image.Store) *ImageCache {
	return &ImageCache{
		store:           store,
		localImageCache: NewLocal(store),
	}
}
1057108
func (ms *FileMsgStore) initCache() {
	ms.cache = &msgsCache{
		seqMaps: make(map[uint64]*cachedMsg),
	}
}
941545
func NewMemcache(conn []string, lifeTime int32) *Memcache {
	rc := &Memcache{}
	rc.c = memcache.New(conn...)
	rc.LifeTime = lifeTime
	return rc
}
759408
func newCache() *cache {
	c := cache{
		m:       make(map[reflect.Type]*structInfo),
		regconv: make(map[reflect.Type]Converter),
		tag:     "schema",
	}
	return &c
}
160550
func NewCache(backend Reader, options ...CacheOption) *Cache {
	cache := &Cache{
		backend:  backend,
		accounts: make(map[crypto.Address]*accountInfo),
	}
	for _, option := range options {
		option(cache)
	}
	return cache
}
823365
func NewPackfileWithCache(
	index idxfile.Index,
	fs billy.Filesystem,
	file billy.File,
	cache cache.Object,
) *Packfile {
	s := NewScanner(file)
	return &Packfile{
		index,
		fs,
		file,
		s,
		cache,
		make(map[int64]plumbing.ObjectType),
	}
}
220309
func NewDiskCache(dir string) (Cache, error) {
	if err := os.MkdirAll(dir, 0777); err != nil {
		return nil, err
	}
	fs, err := vfs.FS(dir)
	if err != nil {
		return nil, err
	}
	chfs, err := vfs.Chroot("/", fs)
	if err != nil {
		return nil, err
	}
	return NewVFSCache(chfs), nil
}
87534
func NewCache() *Cache {
	return &Cache{
		BaseObservableResourceSource: NewBaseObservableResourceSource(),
		resources:                    make(map[cacheKey]cacheValue),
		version:                      1,
	}
}
542786
func NewFileStorage(path string) (ResponseStorage, error) {
	file, err := ioutil.TempFile(path, "caddy-cache-")
	if err != nil {
		return nil, err
	}
	return &FileStorage{
		file:         file,
		subscription: NewSubscription(),
	}, nil
}
765609
func NewCache(c Coser) Coser {
	return &cache{
		Coser:     c,
		cache:     make(map[string]float32),
		errCache:  make(map[string]error),
		cosnCache: make(map[string][]Match),
	}
}
398351
func (o *cacheOnce) cache(f func() error) {
	if atomic.LoadUint32(&o.done) == 1 {
		return
	}
	// Slow-path.
	o.m.Lock()
	defer o.m.Unlock()
	if o.done == 0 {
		err := f()
		if err == nil {
			atomic.StoreUint32(&o.done, 1)
		}
	}
}
1124330
func NewDisk(policies Policies, path, namespace string) (Cache, error) {
	if !filepath.IsAbs(path) {
		return nil, errors.New("must use absolute path")
	}
	d := &disk{
		policies: policies,
		path:     path,
		h:        isolated.GetHash(namespace),
		lru:      makeLRUDict(namespace),
	}
	p := d.statePath()
	f, err := os.Open(p)
	if err == nil {
		defer f.Close()
		err = json.NewDecoder(f).Decode(&d.lru)
	} else if os.IsNotExist(err) {
		// The fact that the cache is new is not an error.
		err = nil
	}
	return d, err
}
1254482
func New(maxSize uint64) *Cache {
	return &Cache{
		cache:   make(map[string]element),
		maxSize: maxSize,
	}
}