NewCache takes a cache config. Returns a new Cache instance and an error if the underlying cache returns an error during configuration.
(config Config)
| 126 | // NewCache takes a cache config. Returns a new Cache instance and an error if the underlying |
| 127 | // cache returns an error during configuration. |
| 128 | func NewCache(config Config) (Cache, error) { |
| 129 | if cache, err := lru.New(config.MaxSize); err != nil { |
| 130 | return Cache{}, fmt.Errorf("error creating cache: %w", err) |
| 131 | } else { |
| 132 | return Cache{lru: cache}, nil |
| 133 | } |
| 134 | } |