summaryrefslogtreecommitdiffhomepage
path: root/util/cache/none.go
blob: e3e53e0b48e2a7fd9df76ac63503a77cf1bc0c5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause

package cache

// None provides no caching and always calls the provided FillFunc.
//
// It is safe for concurrent use if the underlying FillFunc is.
type None[K comparable, V any] struct{}

// Get always calls the provided FillFunc and returns what it does.
func (c None[K, V]) Get(_ K, f FillFunc[V]) (V, error) {
	v, _, e := f()
	return v, e
}

// Forget implements Cache.
func (c None[K, V]) Forget() {}