Option to store null values into the local cache
See original GitHub issueIs your feature request related to a problem? Please describe.
I have an application that is using Hazelcast “near cache” extensively and I’m evaluating a migration to Redis using Redisson “local cache” because I would like to use the AWS ElastiCache Redis service. This application does thousands of cache reads for every user request, so the “local cache” is really needed.
For testing purposes, I launched the same request twice to this application using Hazelcast and twice using Redis, and I saw that the second execution time for the Redis application was higher than the second execution time for the Hazelcast application. It was very surprising considering that the second request should read the data from the “local cache” (redisson).
I debugged the application code and I found that it does hundreds of cache misses. On the othe hand, I found that Redisson only updates the local cache when reading the map value from redis gives a not null value. This redisson code is in RedissonLocalCachedMap.getAsync()
:
future.onComplete((value, e) -> {
(...)
if (value != null) {
cachePut(cacheKey, key, value);
}
});
So, considering that our application does hundreds of cache misses and that Redisson local cache always tries to read the value from redis (even when it tried to read the same key before), it is reasonable that our application performs worse than expected.
Describe the solution you’d like
In order to improve our application performance when using Redis I think that it would be helpful to be able to add null values to the Redisson local cache, maybe adding an extra option in LocalCachedMapOptions
; something like cacheNullValues
, with a false
value by default. I think that something related was fixed in #928 and #853
Describe alternatives you’ve considered
I have not considered an alternative 😞
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:5 (4 by maintainers)
Yeah. Please add
allowNullValues
setting toLocalCachedMapOptions
object.@theigl
I created separate issue for this task https://github.com/redisson/redisson/issues/3313