StackExchange.Redis icon indicating copy to clipboard operation
StackExchange.Redis copied to clipboard

KeyMigrate with authentication

Open olsh opened this issue 2 years ago • 1 comments

Can the KeyMigrate method be used against the target database with a password? The migrate command supports AUTH option, but I didn't find it in the library.

Here is the code that I use

var source = ConnectionMultiplexer.Connect("127.0.0.1:6381");
var sourceDatabase = source.GetDatabase(5);
var sourceServer = source.GetServer("127.0.0.1", 6381);

var target = ConnectionMultiplexer.Connect("127.0.0.1:6379,password=my_password");
var targetEndPoint = target.GetEndPoints().Single();
await foreach (var key in sourceServer.KeysAsync(5))
{
    await sourceDatabase.KeyMigrateAsync(key, targetEndPoint, 5, 10000, MigrateOptions.Copy | MigrateOptions.Replace)
        .ConfigureAwait(false);
}

olsh avatar May 16 '23 09:05 olsh

Indeed we do not support this today, and should. For an immediate workaround, you can use .ExecuteAsync() today.

Tagging this for API addition.

NickCraver avatar Aug 02 '23 11:08 NickCraver