Skip to content
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

How to configure hibernate second level and spring cache the same redissonclient? #122

Open
kutuni opened this issue Jul 16, 2018 · 2 comments

Comments

@kutuni
Copy link

kutuni commented Jul 16, 2018

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)

@ti3r
Copy link
Contributor

ti3r commented Sep 28, 2018

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?

@kutuni
Copy link
Author

kutuni commented Oct 8, 2018

It's good idea. I am waiting...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants