none.go 589 B

1234567891011121314151617181920212223
  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. var _ Cache[int, int] = None[int, int]{}
  9. // Get always calls the provided FillFunc and returns what it does.
  10. func (c None[K, V]) Get(_ K, f FillFunc[V]) (V, error) {
  11. v, _, e := f()
  12. return v, e
  13. }
  14. // Forget implements Cache.
  15. func (None[K, V]) Forget(K) {}
  16. // Empty implements Cache.
  17. func (None[K, V]) Empty() {}