How to configure hibernate second level and spring cache the same redissonclient?
kutuni opened this issue · 2 comments
How to configure hibernate second level and spring cache the same redissonclient?
My solution is access redissonClient after initialized SingletonRedisRegionFactory, than construct RedissonSpringCacheManager with redissonClient;
it can Programaticly like below (2 class)
public class XRedisFactory extends SingletonRedisRegionFactory {
private static RedissonClient redissonClient = null;
public CMRedisFactory(Properties props) {
super(props);
}
public void start(SessionFactoryOptions options, Properties properties) throws CacheException {
super.start(options, properties);
redissonClient = super.redis.getRedisson();
}
public static RedissonClient getRedissonClient() {
return redissonClient;
}
}
public class XRedisClient extends RedissonSpringCacheManager {
public XRedisClient() {
super(XRedisFactory.getRedissonClient());
}
}
is there any efficient way ? (whithout code)
We had a similar problem, little difference is that we wanted to build a HealthIndicator for the client used in the region factory. We ended up creating a whole new client using the same Config object as the RegionFactory just to check the status.
I'm planning on opening a PR to fix it. Maybe using final RedisCacheUtil class to store a reference to the client?
It's good idea. I am waiting...