-
Notifications
You must be signed in to change notification settings - Fork 25
pkg/services/orgresolver: add cached OrgResolver #1798
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
base: main
Are you sure you want to change the base?
Conversation
✅ API Diff Results - No breaking changes |
be861a7 to
266bb5c
Compare
| cacheDurationOrg = 24 * time.Hour | ||
| cacheDurationError = time.Minute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patrickhuie19 are these reasonable? Do we need to be able to reconfigure them?
| stop, done chan struct{} | ||
| } | ||
|
|
||
| func NewCache(orgResolver OrgResolver) OrgResolver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would not you like just to wrap github.com/hashicorp/golang-lru/v2/expirable ?
For example, it does not have additional background routines and only updates stuff once it is read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, taking it back - seems a different type of hash. However, I still have this question - why do you need the background reap routine? Cannot you update the entries whenever you read them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was being overly cautious about memory leaks 🤷 Could manage a max size instead, but that seems to come with other complexities 🤷 Open to suggestions though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we already use external cache in a couple of places https://github.com/search?q=org%3Asmartcontractkit+%22jellydator%2Fttlcache%22&type=code .
So, I would suggest to do the same here - use https://pkg.go.dev/github.com/jellydator/ttlcache which ensures that the cache does not leak and has customizable behavior for the load.
266bb5c to
254b3c0
Compare
https://smartcontract-it.atlassian.net/browse/CRE-1707
Supports: