Replace the iprules LRU with an lru.LRU#11579
Conversation
365d047 to
b2fa573
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the IP rules in-memory cache implementation to use the shared server/util/lru cache (with TTL + thread-safety) instead of a custom LRU wrapper, aligning with the expiring LRU work from #11565.
Changes:
- Replace the custom
memIpRuleCacheimplementation with a genericlru.LRU[[]*net.IPNet]. - Update the cache interface to match
lru.LRU’sAddsignature (returnsbool). - Configure the cache with TTL-based expiry and thread-safety.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| return lru.New[[]*net.IPNet](&lru.Config[[]*net.IPNet]{ | ||
| TTL: *cacheTTL, | ||
| MaxSize: cacheSize, | ||
| ThreadSafe: true, |
There was a problem hiding this comment.
this seems like a good suggestion
There was a problem hiding this comment.
Yeah, definitely. Fixed.
There was a problem hiding this comment.
Also added a test that caught this
enterprise/server/iprules/iprules.go
Outdated
| return &memIpRuleCache{ | ||
| lru: l, | ||
| }, nil | ||
| return lru.New[[]*net.IPNet](&lru.Config[[]*net.IPNet]{ |
There was a problem hiding this comment.
nit: also don't need the type parameter on New here.
| return lru.New[[]*net.IPNet](&lru.Config[[]*net.IPNet]{ | ||
| TTL: *cacheTTL, | ||
| MaxSize: cacheSize, | ||
| ThreadSafe: true, |
There was a problem hiding this comment.
this seems like a good suggestion
b2fa573 to
af079c6
Compare
af079c6 to
d4792a8
Compare
Depends on: #11565