// NewCacheStore creates an Indexer store with the given key function
14043
func NewCacheStore(keyFn cache.KeyFunc) cache.Indexer {
	return cache.NewIndexer(keyFn, cache.Indexers{
		"requester": indexNamespaceByRequester,
	})
}
1043266
func newClient(scope string, kv string, addr string, config *store.Config, cached bool) (DataStore, error) {

	if cached && scope != LocalScope {
		return nil, fmt.Errorf("caching supported only for scope %s", LocalScope)
	}
	sequential := false
	if scope == LocalScope {
		sequential = true
	}

	if config == nil {
		config = &store.Config{}
	}

	var addrs []string

	if kv == string(store.BOLTDB) {
		// Parse file path
		addrs = strings.Split(addr, ",")
	} else {
		// Parse URI
		parts := strings.SplitN(addr, "/", 2)
		addrs = strings.Split(parts[0], ",")

		// Add the custom prefix to the root chain
		if len(parts) == 2 {
			rootChain = append([]string{parts[1]}, defaultRootChain...)
		}
	}

	store, err := libkv.NewStore(store.Backend(kv), addrs, config)
	if err != nil {
		return nil, err
	}

	ds := &datastore{scope: scope, store: store, active: true, watchCh: make(chan struct{}), sequential: sequential}
	if cached {
		ds.cache = newCache(ds)
	}

	return ds, nil
}
1059331
func NewMemStore(params *StoreParams, _ *LDBStore) (m *MemStore) {
	if params.CacheCapacity == 0 {
		return &MemStore{
			disabled: true,
		}
	}

	c, err := lru.New(int(params.CacheCapacity))
	if err != nil {
		panic(err)
	}

	return &MemStore{
		cache: c,
	}
}
1218546
func NewKeyFileStore(baseDir string, p notary.PassRetriever) (*GenericKeyStore, error) {
	fileStore, err := store.NewPrivateKeyFileStorage(baseDir, notary.KeyExtension)
	if err != nil {
		return nil, err
	}
	return NewGenericKeyStore(fileStore, p), nil
}
1335745
func NewCache(maxEntries int, ttl time.Duration, staticTTL bool,
	onEvicted func(itmID string, value interface{})) (c *Cache) {
	c = &Cache{
		cache:      make(map[string]*cachedItem),
		groups:     make(map[string]map[string]struct{}),
		onEvicted:  onEvicted,
		maxEntries: maxEntries,
		ttl:        ttl,
		staticTTL:  staticTTL,
		lruIdx:     list.New(),
		lruRefs:    make(map[string]*list.Element),
		ttlIdx:     list.New(),
		ttlRefs:    make(map[string]*list.Element),
	}
	if c.ttl > 0 {
		go c.cleanExpired()
	}
	return
}
868811
func NewInMemStore() Store {
	return &inmem{
		idgen: snowflake.NewIDGenerator(),
		meta:  map[platform.ID]StoreTaskMeta{},
	}
}
1336232
func NewRethinkStore(addr, db, table string, idle, open int, keyPairs ...[]byte) (*RethinkStore, error) {
	session, err := r.Connect(r.ConnectOpts{
		Address:  addr,
		Database: db,
		MaxIdle:  idle,
		MaxOpen:  open,
	})
	if err != nil {
		return nil, err
	}
	rs := &RethinkStore{
		Rethink: session,
		Table:   table,
		Codecs:  securecookie.CodecsFromPairs(keyPairs...),
		Options: &sessions.Options{
			Path:   "/",
			MaxAge: sessionExpire,
		},
	}

	rs.MaxAge(sessionExpire)

	// Create missing db, table and secondary index. Discard error (database exists)
	r.DBCreate(db).RunWrite(session)
	r.DB(db).TableCreate(table).RunWrite(session)

	// Index for removing expired data
	r.Table(table).IndexCreate("expires").Exec(session)
	r.Table(table).IndexWait().RunWrite(session)

	return rs, nil
}
920108
func NewIndexStorage(s, temporal storer.IndexStorer) *IndexStorage {
	return &IndexStorage{
		IndexStorer: s,
		temporal:    temporal,
	}
}
851360
func (i18n *I18n) SetCacheStore(cacheStore cache.CacheStoreInterface) {
	i18n.cacheStore = cacheStore
	i18n.loadToCacheStore()
}
1179614
func NewMemcacherStore(client Memcacher, keyPrefix string, keyPairs ...[]byte) *MemcacheStore {
	return NewMemcacherStoreWithValueStorer(client, &CookieStorer{}, keyPrefix, keyPairs...)
}
447818
func NewKVStore(path string) *KVStore {
	return &KVStore{
		path:   path,
		logger: zap.NewNop(),
	}
}
65098
func New(store image.Store) *ImageCache {
	return &ImageCache{
		store:           store,
		localImageCache: NewLocal(store),
	}
}
1173990
func NewCacheKey(dgst digest.Digest, output Index) *CacheKey {
	return &CacheKey{
		ID:     rootKey(dgst, output).String(),
		digest: dgst,
		output: output,
		ids:    map[*cacheManager]string{},
	}
}
1251644
func NewCache(fs afero.Fs, maxAge time.Duration) *Cache {
	return &Cache{
		Fs:      fs,
		nlocker: &lockTracker{Locker: locker.NewLocker(), seen: make(map[string]struct{})},
		maxAge:  maxAge,
	}
}
220425
func New(e *xorm.Engine, keyPairs ...[]byte) (*Store, error) {
	return NewOptions(e, Options{}, keyPairs...)
}
1046525
func NewKeyMemoryStore(p notary.PassRetriever) *GenericKeyStore {
	memStore := store.NewMemoryStore(nil)
	return NewGenericKeyStore(memStore, p)
}
796039
func NewStore(
	client *memcache.Client, keyPrefix string, keyPairs ...[]byte,
) Store {
	memcacherClient := gsm.NewGoMemcacher(client)
	return NewMemcacheStore(memcacherClient, keyPrefix, keyPairs...)
}