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内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复