-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use value object for topology caching #2989
Conversation
We now use a value object for caching the topology to avoid races in updating the cache timestamp. Also, we set the cache timestamp after obtaining the topology to avoid that I/O latency expires the topology cache. Closes #2986
if (shouldUseCachedValue(topology)) { | ||
return topology; |
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.
the previous shouldUseCachedValue()
would no longer be called in the patch targeting 3.3.4
so I was wondering if it makes senes to keep the arrangement stable for the SR and changing it for the 3.4
version.
For 3.3.4 we could have
protected boolean shouldUseCachedValue() {
return shouldUseCachedValue(cached);
}
and call the old method.
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.
Feel free to apply these changes in the merge.
* @since 3.3.4 | ||
*/ | ||
protected boolean shouldUseCachedValue(@Nullable JedisClusterTopology topology) { | ||
return topology != null && topology.getTime() + cacheTimeMs > System.currentTimeMillis(); |
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.
we could move the cacheTimeMs
to the JedisClusterTopology
having a package private method maxTime
that does the calculation.
Move maxTime calculation for topology refresh to and delegate shouldUseCachedValue() to newly introduced overload. Original Pull Request: #2989
Move maxTime calculation for topology refresh to and delegate shouldUseCachedValue() to newly introduced overload. Retain application flow as much as possible. Original Pull Request: #2989
We now use a value object for caching the topology to avoid races in updating the cache timestamp.
Also, we set the cache timestamp after obtaining the topology to avoid that I/O latency expires the topology cache.
Closes #2986