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