Open pbarsotti-glovo opened 3 years ago
MappingExpirationListener
is an internal component that cannot be configured externally. It registers for __keyevent@*__:expired
which matches notifications for all keys. In theory, there could be two approaches:
@RedisHash
types need to be registered upfront so that the MappingContext
can provide details about the keyspace prefix. If an entity wasn't registered at that time, it could easily lead to dropped notifications.Going forward, opening up MappingExpirationListener
and RedisKeyValueAdapter
for customization through subclassing seems the most promising approach.
Thanks @mp911de for the response. I see all the options require modifications in the library. How is this handled usually? A solution is discussed in the issue and then anyone can submit a PR following the agreed approach?
Yes, typically someone crafts a pull request. External contributions speed up the entire process whereas waiting for us typically takes a bit longer.
Working on a legacy application which uses a single Redis cluster, I found a mixed scenario where Redis repositories are enabled and also the same cluster is used for a
RedisCacheManager
.Due to the use of repositories, this routine is executed on
MappingExpirationListener
upon the expiration of each element in the cluster. In order to determine if the key should be processed, a validity check is performed. Valid keys must contain at least one delimiter:
as we can see here.We use the same cluster for caching, and some keys contain the delimiter value
:
, so the listener is trying to execute the routine with them. Unfortunately, due to the nature of the cached values we end up having keys with the formatFIXED_PART:VARIABLE_PART
, so the listener is misinterpreting the key, and tries to perform aSREM(FIXED_PART, VARIABLE_PART)
as we can see here. This leads to a high throughput in one node of the cluster (the one whereFIXED_PART
is assigned).I was thinking about adding a prefix to the cached keys and then a filtering layer in the listener to discard them if they start with the prefix, but
MappingExpirationListener
is instantiated insideRedisKeyValueAdapter
and there is no possibility to replace it.Is there any known way to handle this type of situation?
Thanks!