-
Notifications
You must be signed in to change notification settings - Fork 29
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
Rate control 273 #483
Rate control 273 #483
Conversation
cache.go
Outdated
// defined at the cache creation | ||
// The implementation is robust against concurrent call | ||
type cacheTTL struct { | ||
entries map[interface{}]*cacheTTLEntry |
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.
Typically it's better to use value types instead of pointer types like interface{}
as keys. that's because two different pointers might have the same value which will create duplicates in the cache. The functions where Set/Get
is called like RegisterRoster
and RegisterTree
often take parameters that originate from the network. So, if Set
gets called, then Get
gets called somewhere else on something that has the same value but a different address, then the cache will miss.
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 think RosterID
and TreeID
are, at the end of the day, array types, so maybe setting the key to [32]byte
will work.
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.
sorry, my bad. I did not notice that cacheTTL
is like an abstract class. the entries are concrete type when implemented.
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.
so as discussed and to reduce confusion I changed the key to be of UUID type (instead of the raw type to avoid breaking changes from the package)
Is it possible to use your new cache structure for |
Yes totally, I'm going to move the logic |
This PR improves caching of Tree and Roster in the overlay implementation by adding an expiration to cached entries.
Fixes #273