Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/lru: add Clear method #12176

Merged
merged 1 commit into from
May 18, 2024
Merged

util/lru: add Clear method #12176

merged 1 commit into from
May 18, 2024

Conversation

andrew-d
Copy link
Member

Updates tailscale/corp#20109

Change-Id: I751a669251a70f0134dd1540c19b274a97608a93

@andrew-d andrew-d requested a review from maisem May 17, 2024 23:51
Updates tailscale/corp#20109

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I751a669251a70f0134dd1540c19b274a97608a93
@@ -68,6 +68,12 @@ func (c *Cache[K, V]) Set(key K, value V) {
}
}

// Clear removes all items from the cache.
func (c *Cache[K, V]) Clear() {
c.head = nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about *c = Cache[K,V]{MaxEntries: c.MaxEntries}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of the "assign to struct receiver" pattern, thing; it's a bit confusing if you haven't seen it.

@andrew-d
Copy link
Member Author

(test failure is unrelated)

@andrew-d andrew-d merged commit 47b3476 into main May 18, 2024
46 of 48 checks passed
@andrew-d andrew-d deleted the andrew/lru-clear branch May 18, 2024 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants