func NewContentCache(ctx context.Context, st blob.Storage, opt Options) (ContentCache, error) {
	cacheStorage := opt.Storage
	if cacheStorage == nil {
		if opt.BaseCacheDirectory == "" {
			return passthroughContentCache{st}, nil
		}

		var err error

		cacheStorage, err = NewStorageOrNil(ctx, opt.BaseCacheDirectory, opt.Sweep.MaxSizeBytes, opt.CacheSubDir)
		if err != nil {
			return nil, errors.Wrap(err, "error initializing cache storage")
		}
	}

	pc, err := NewPersistentCache(ctx, opt.CacheSubDir, cacheStorage, ChecksumProtection(opt.HMACSecret), opt.Sweep)
	if err != nil {
		return nil, errors.Wrap(err, "unable to create base cache")
	}

	return &contentCacheImpl{
		st:             st,
		pc:             pc,
		fetchFullBlobs: opt.FetchFullBlobs,
	}, nil
}
// NewContentCache creates new content cache for data contents.
NewContentCache creates new content cache for data contents.
// NewContentCache creates new content cache for data contents .
func NewContentCache(ctx context.Context, st blob.Storage, opt Options) (ContentCache, error) {
	cacheStorage := opt.Storage
	if cacheStorage == nil {
		if opt.BaseCacheDirectory == "" {
			return passthroughContentCache{st}, nil
		}
		var err error
		cacheStorage, err = NewStorageOrNil(ctx, opt.BaseCacheDirectory, opt.Sweep.MaxSizeBytes, opt.CacheSubDir)
		if err != nil {
			return nil, errors.Wrap(err, "error initializing cache storage")
		}
	}
	pc, err := NewPersistentCache(ctx, opt.CacheSubDir, cacheStorage, ChecksumProtection(opt.HMACSecret), opt.Sweep)
	if err != nil {
		return nil, errors.Wrap(err, "unable to create base cache")
	}
	return &contentCacheImpl{
		st:             st,
		pc:             pc,
		fetchFullBlobs: opt.FetchFullBlobs,
	}, nil
}
func NewContentCache ( ctx context . Context , st blob . Storage , opt Options ) ( ContentCache , error ) { cacheStorage := opt . Storage if cacheStorage == nil { if opt . BaseCacheDirectory == " " { return passthroughContentCache { st } , nil } var err error cacheStorage , err = NewStorageOrNil ( ctx , opt . BaseCacheDirectory , opt . Sweep . MaxSizeBytes , opt . CacheSubDir ) if err != nil { return nil , errors . Wrap ( err , " " ) } } pc , err := NewPersistentCache ( ctx , opt . CacheSubDir , cacheStorage , ChecksumProtection ( opt . HMACSecret ) , opt . Sweep ) if err != nil { return nil , errors . Wrap ( err , " " ) } return & contentCacheImpl { st : st , pc : pc , fetchFullBlobs : opt . FetchFullBlobs , } , nil }
NewContentCache creates new content cache for data contents.
NewContentCache creates new content cache for data contents .