func (fc *FCache) lookup(o lookupOptions) (*Future, error) {
	// Lock the cache
	fc.Lock()
	defer fc.Unlock()

	// Look for the index
	idx, ok := fc.indexes[o.key.Index]
	if !ok {
		return nil, ErrBadIndex
	}

	// Find an existing entry, constructing it if needed
	ent, ok := idx.entries[o.key.Key]
	if !ok {
		// Not present; insert entry if one was passed
		if o.ent != nil {
			e := fc.insert(o.ent)
			return e.makeFuture(fc), nil
		}

		// Only searching the cache?
		if o.only {
			return nil, ErrNotCached
		}

		// Construct a new entry
		var ctx context.Context
		ent, ctx = newEntry()
		idx.entries[o.key.Key] = ent

		// Manufacture the entry
		go fc.manufacture(ctx, *o.key, idx.factory)
	}

	// If the entry is incomplete and we're only searching the
	// cache, stop here
	if ent.content == nil && o.only {
		return nil, ErrNotCached
	}

	// Construct and return a future
	return ent.makeFuture(fc), nil
}
// lookup looks up an entry in the cache and returns a Future.  The
// Lookup and LookupFuture methods use lookup to perform the actual
// lookup.
lookup looks up an entry in the cache and returns a Future.  The
Lookup and LookupFuture methods use lookup to perform the actual
lookup.
// lookup looks up an entry in the cache and returns a Future . The // Lookup and LookupFuture methods use lookup to perform the actual // lookup .
func (fc *FCache) lookup(o lookupOptions) (*Future, error) {
	fc.Lock()
	defer fc.Unlock()
	idx, ok := fc.indexes[o.key.Index]
	if !ok {
		return nil, ErrBadIndex
	}
	ent, ok := idx.entries[o.key.Key]
	if !ok {
		if o.ent != nil {
			e := fc.insert(o.ent)
			return e.makeFuture(fc), nil
		}
		if o.only {
			return nil, ErrNotCached
		}
		var ctx context.Context
		ent, ctx = newEntry()
		idx.entries[o.key.Key] = ent
		go fc.manufacture(ctx, *o.key, idx.factory)
	}
	if ent.content == nil && o.only {
		return nil, ErrNotCached
	}
	return ent.makeFuture(fc), nil
}
func ( fc * FCache ) lookup ( o lookupOptions ) ( * Future , error ) { fc . Lock ( ) defer fc . Unlock ( ) idx , ok := fc . indexes [ o . key . Index ] if ! ok { return nil , ErrBadIndex } ent , ok := idx . entries [ o . key . Key ] if ! ok { if o . ent != nil { e := fc . insert ( o . ent ) return e . makeFuture ( fc ) , nil } if o . only { return nil , ErrNotCached } var ctx context . Context ent , ctx = newEntry ( ) idx . entries [ o . key . Key ] = ent go fc . manufacture ( ctx , * o . key , idx . factory ) } if ent . content == nil && o . only { return nil , ErrNotCached } return ent . makeFuture ( fc ) , nil }
lookup looks up an entry in the cache and returns a Future.
lookup looks up an entry in the cache and returns a Future .
// Lock the cache // Look for the index // Find an existing entry, constructing it if needed // Not present; insert entry if one was passed // Only searching the cache? // Construct a new entry // Manufacture the entry // If the entry is incomplete and we're only searching the // cache, stop here // Construct and return a future