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

deps: upgrade to hashicorp/golang-lru/v2 #16085

Merged
merged 1 commit into from
Feb 8, 2023
Merged

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Feb 7, 2023

Upgrade to hashicorp/golang-lru/v2, and refactor the ACL cache to leverage all the generics. Previously each cache entry contained 3 pointers, only one of which would be in use - so we should get some space savings out of that (not that the cache sizes are large).

@shoenig shoenig force-pushed the update-golang-lru-v2 branch 2 times, most recently from 9e97c01 to 2436afa Compare February 7, 2023 20:58
@shoenig shoenig changed the title acl: upgrade to hashicorp/golang-lru/v2 deps: upgrade to hashicorp/golang-lru/v2 Feb 7, 2023
@shoenig shoenig force-pushed the update-golang-lru-v2 branch from 2436afa to 633cef7 Compare February 7, 2023 21:02
@shoenig shoenig force-pushed the update-golang-lru-v2 branch from 633cef7 to b85d9b3 Compare February 7, 2023 21:10
@shoenig shoenig force-pushed the update-golang-lru-v2 branch from b85d9b3 to d771f9d Compare February 7, 2023 21:18
@shoenig shoenig force-pushed the update-golang-lru-v2 branch from d771f9d to 13dbfb7 Compare February 7, 2023 21:46
@shoenig shoenig force-pushed the update-golang-lru-v2 branch from 13dbfb7 to 758862e Compare February 7, 2023 22:11
@shoenig shoenig force-pushed the update-golang-lru-v2 branch 2 times, most recently from d7a844e to e86a86e Compare February 7, 2023 22:21
@shoenig shoenig force-pushed the update-golang-lru-v2 branch from e86a86e to fd00d4e Compare February 7, 2023 22:31
@shoenig shoenig force-pushed the update-golang-lru-v2 branch from fd00d4e to a3ae76d Compare February 8, 2023 00:28
@shoenig shoenig force-pushed the update-golang-lru-v2 branch from a3ae76d to b10620d Compare February 8, 2023 19:54
@shoenig shoenig force-pushed the update-golang-lru-v2 branch from b10620d to 6d2ac54 Compare February 8, 2023 19:55
@shoenig shoenig added this to the 1.5.0 milestone Feb 8, 2023
@shoenig shoenig marked this pull request as ready for review February 8, 2023 20:10
@shoenig shoenig requested review from jrasell and tgross February 8, 2023 20:10
Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

LGTM! I love the added type-safety this gives us everywhere it's used.

ValidACLAuthMethod = regexp.MustCompile("^[a-zA-Z0-9-]{1,128}$")
)

type ACLCacheEntry[T any] lang.Pair[T, time.Time]
Copy link
Member

Choose a reason for hiding this comment

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

Just for my education, what does lang.Pair get us over something like this?

type ACLCacheEntry[T any] struct { 
  val T
  t time.Time
}

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just a way to signal the (combined) type is irrelevant - it's an implementation detail of the cache, so there isn't much need to declare a whole type around it

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, cool. There's probably a bunch of other places this would be handy too.

@shoenig shoenig merged commit 7798fe3 into main Feb 8, 2023
@shoenig shoenig deleted the update-golang-lru-v2 branch February 8, 2023 21:20
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.

2 participants