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
Add evictions metrics support for RedissonCache #4739
Add evictions metrics support for RedissonCache #4739
Conversation
ff7798d
to
e1dcd7f
Compare
@@ -46,11 +46,14 @@ public class RedissonCache implements Cache { | |||
private final AtomicLong puts = new AtomicLong(); | |||
|
|||
private final AtomicLong misses = new AtomicLong(); | |||
|
|||
private AtomicLong evictions; |
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.
please make it final and init in field.
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 initialising it in one of the constructor and not in the other one as I wanted to signal that in one case we can count evictions but not in the other one. Does it makes sense?
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, which case? I think we need to calculate it the same way we do for other metrics
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.
Oh yes I see, I was wrong with my assumption, sorry, I'll fix this
|
||
public RedissonCache(RMapCache<Object, Object> mapCache, CacheConfig config, boolean allowNullValues) { | ||
this(mapCache, allowNullValues); | ||
this.mapCache = mapCache; | ||
this.config = config; | ||
this.evictions = new AtomicLong(); |
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.
it should be initialized in the field
@@ -238,6 +242,12 @@ long getCacheMisses(){ | |||
long getCachePuts() { | |||
return puts.get(); | |||
} | |||
|
|||
Long getCacheEvictions() { | |||
return evictions != null |
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.
evictions can't be null
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.
It is null, when this cache is backed by RMap (created with: public RedissonCache(RMap<Object, Object> map, boolean allowNullValues)
constructor)
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.
this is why I asked to init it in the field
@@ -251,4 +261,9 @@ private void addCacheMiss(){ | |||
misses.incrementAndGet(); | |||
} | |||
|
|||
private void addCacheEvictions(long delta) { | |||
if (this.evictions != null) { |
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.
evictions can't be null
@mrniko thanks a lot for the review! I added some consideration on why I am using a nullable evictions counter However, I can add a boolean to signal whether the cache supports evictions, and in |
Thanks for the contribution! But |
e1dcd7f
to
67407f0
Compare
You are right, thanks! I amended my commit :) |
@mrniko As this is my first contribution, could I ask you how your release cycle works? What's the timeframe you usually allocate for a new release to come out? |
That's depends on the importance of the changes made in release |
Ok thanks! |
Signed-off-by: Nicola Dardanis <ndardanis@adobe.com>
67407f0
to
3b937e2
Compare
Currently,
RedissonCache
(aka the implementationorg.springframework.cache.Cache
) supports some metrics (hits, misses, puts) but evictions are not taken into account.