diff options
| author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2024-09-15 08:56:16 -0700 |
|---|---|---|
| committer | Patrick O'Doherty <patrick@tailscale.com> | 2024-12-11 13:27:58 -0800 |
| commit | ef68b4c0045936c88fa09bc7bcd1282e3b0d176a (patch) | |
| tree | 6a8e21b7f3570bb799a163e276175dc209db7e98 /util | |
| parent | 6e552f66a0289f6309477fb024019b62a251da16 (diff) | |
| download | tailscale-patrickod/bradtfitz-flow-rebased.tar.xz tailscale-patrickod/bradtfitz-flow-rebased.zip | |
derp: start adding flow tracking statspatrickod/bradtfitz-flow-rebased
This starts adding flow tracking stats, without exposing them anywhere
yet. Flow structs are created as needed and metrics are bumped, and
benchmarks show no change in performance.
Updates #3560
Change-Id: I376187a8452ec92d49effcbf48a6fb4f4d787b8a
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Diffstat (limited to 'util')
| -rw-r--r-- | util/lru/lru.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/util/lru/lru.go b/util/lru/lru.go index 8e4dd417b..d4e836cf1 100644 --- a/util/lru/lru.go +++ b/util/lru/lru.go @@ -133,6 +133,15 @@ func (c *Cache[K, V]) DeleteOldest() { } } +// OldestKey returns the oldest key, without bumping it to the head. +// If the cache is empty, it returns ok false. +func (c *Cache[K, V]) OldestKey() (key K, ok bool) { + if c.head == nil { + return key, false + } + return c.head.prev.key, true +} + // Len returns the number of items in the cache. func (c *Cache[K, V]) Len() int { return len(c.lookup) } |
