I have two services, A and B.
Service A is a service that exposes an API users can use to configure the system and service B processes records according to configuration from service A.
Service B uses a RLocalCachedMap to cache various aspects of configuration using CompositeCodec(StringCodec.INSTANCE, new MarshallingCodec())
for simple String keys, and marshalled values.
Service B cache configuration
LocalCachedMapOptions options = LocalCachedMapOptions.defaults()
.evictionPolicy(LocalCachedMapOptions.EvictionPolicy.LRU)
.cacheSize(250)
.timeToLive(15, TimeUnit.MINUTES)
.storeMode(LocalCachedMapOptions.StoreMode.LOCALCACHE_REDIS)
.writeMode(MapOptions.WriteMode.WRITE_THROUGH)
.syncStrategy(LocalCachedMapOptions.SyncStrategy.INVALIDATE)
.reconnectionStrategy(LocalCachedMapOptions.ReconnectionStrategy.CLEAR);
cache = redissonClient.getLocalCachedMap("config", new CompositeCodec(StringCodec.INSTANCE, new MarshallingCodec()), options);
Now service A doesn't have any of the classes on its class path from Service B so is unable to unmarshall the values.
When the user makes a configuration change in Service A, I need to invalidate keys matching a pattern from the hash and am attempting to do it this way
String keyPattern = String.join("-", customerContext.getCustomerId().toString(), "*");
LocalCachedMapOptions options = LocalCachedMapOptions.defaults().storeMode(LocalCachedMapOptions.StoreMode.LOCALCACHE_REDIS)
.writeMode(MapOptions.WriteMode.WRITE_THROUGH)
.syncStrategy(LocalCachedMapOptions.SyncStrategy.INVALIDATE);
RLocalCachedMap<String, Object> cache = redissonClient.getLocalCachedMap("config", new CompositeCodec(StringCodec.INSTANCE, new MarshallingCodec()), options);
cache.fastRemove(cache.keySet(keyPattern).toArray(String[]::new));
The issue I'm having is that even though I'm just using keySet()
I am running into Caused by: java.lang.ClassNotFoundException: com.redacted.Class
as Redisson attempts to unmarshall the value.
Is there any way I can invalidate keys from a RLocalCachedMap from a service unable to unmarshall their values and have these invalidations propagated to other instances?