none.go 491 B

123456789101112131415161718
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package cache
  4. // None provides no caching and always calls the provided FillFunc.
  5. //
  6. // It is safe for concurrent use if the underlying FillFunc is.
  7. type None[K comparable, V any] struct{}
  8. // Get always calls the provided FillFunc and returns what it does.
  9. func (c None[K, V]) Get(_ K, f FillFunc[V]) (V, error) {
  10. v, _, e := f()
  11. return v, e
  12. }
  13. // Forget implements Cache.
  14. func (c None[K, V]) Forget() {}