我是靠谱客的博主 俭朴玉米,这篇文章主要介绍redistemplate动态切换dbindex,现在分享给大家,希望可以做个参考。

redisTemplate.getConnectionFactory().getConnection().select(uvIndex);  依据api  此代码可以切换dbindex,不过实际没有生效!

 

找了找原因:是我用法有问题

 

正确写法应该是

JedisConnectionFactory factory =
(JedisConnectionFactory) redisTemplate.getConnectionFactory();
factory.setDatabase(dbIndex);//dbindex就是你想切换的db
redisTemplate.setConnectionFactory(factory);

 参考链接 https://blog.csdn.net/jlh912008548/article/details/78982008

最后

以上就是俭朴玉米最近收集整理的关于redistemplate动态切换dbindex的全部内容,更多相关redistemplate动态切换dbindex内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(109)

评论列表共有 0 条评论

立即
投稿
返回
顶部