func New(indexes ...Index) (*FCache, error) {
	// Make sure we have at least one index
	if len(indexes) < 1 {
		return nil, ErrMissingIndex
	}

	// Construct the cache
	fc := &FCache{
		indexes: map[interface{}]index{},
	}

	// Process all the indexes
	for _, idx := range indexes {
		if _, ok := fc.indexes[idx.Index]; ok {
			return nil, ErrDuplicateOption
		}
		if idx.Factory == nil {
			return nil, ErrMissingFactory
		}

		fc.indexes[idx.Index] = index{
			factory: idx.Factory,
			entries: map[interface{}]*entry{},
		}
	}

	return fc, nil
}
// New constructs a new FCache object and returns it.  At least one
// Index must be passed, and all indexes must define both the index
// key and the factory function to call when the requested entry does
// not exist in the cache.
New constructs a new FCache object and returns it.  At least one
Index must be passed, and all indexes must define both the index
key and the factory function to call when the requested entry does
not exist in the cache.
// New constructs a new FCache object and returns it . At least one // Index must be passed and all indexes must define both the index // key and the factory function to call when the requested entry does // not exist in the cache .
func New(indexes ...Index) (*FCache, error) {
	if len(indexes) < 1 {
		return nil, ErrMissingIndex
	}
	fc := &FCache{
		indexes: map[interface{}]index{},
	}
	for _, idx := range indexes {
		if _, ok := fc.indexes[idx.Index]; ok {
			return nil, ErrDuplicateOption
		}
		if idx.Factory == nil {
			return nil, ErrMissingFactory
		}
		fc.indexes[idx.Index] = index{
			factory: idx.Factory,
			entries: map[interface{}]*entry{},
		}
	}
	return fc, nil
}
func New ( indexes ... Index ) ( * FCache , error ) { if len ( indexes ) < 1 { return nil , ErrMissingIndex } fc := & FCache { indexes : map [ interface { } ] index { } , } for _ , idx := range indexes { if _ , ok := fc . indexes [ idx . Index ] ; ok { return nil , ErrDuplicateOption } if idx . Factory == nil { return nil , ErrMissingFactory } fc . indexes [ idx . Index ] = index { factory : idx . Factory , entries : map [ interface { } ] * entry { } , } } return fc , nil }
New constructs a new FCache object and returns it.
New constructs a new FCache object and returns it .
// Make sure we have at least one index // Construct the cache // Process all the indexes