RedisTemplate指定操作ライブラリ

623 ワード

redisは複数のライブラリがあり,開発中にAサービス操作のデータが発見され,Bサービスでは調べられなかった.Aサービスオペレーションがdb 0,Bサービスオペレーションのdb 1であることが判明した.
ライブラリのメソッドを指定します.
RedisConnection redisConnection = redisTemplate.getConnectionFactory().getConnection();
DefaultStringRedisConnection stringRedisConnection = new DefaultStringRedisConnection(redisConnection);
stringRedisConnection.select(db);

エラーが発生しました:
Selecting a new database not supported due to shared connection.
Use separate ConnectionFactorys to work with multiple databases

ソリューションリファレンス:https://blog.csdn.net/qq_38846242/article/details/83151489