Skip to content

Commit ff14294

Browse files
committed
Step 3: Add Public API Method to BaseClient
Signed-off-by: currantw <taylor.curran@improving.com>
1 parent caa8452 commit ff14294

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

sources/Valkey.Glide/BaseClient.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,38 @@ public async Task RefreshIamTokenAsync()
5858
}
5959
}
6060

61+
/// <summary>
62+
/// Update the current connection with a new password or remove the password.
63+
/// </summary>
64+
/// <param name="password">The new password to update the connection with, or <c>null</c> to remove the password</param>
65+
/// <param name="immediateAuth">If <c>true</c>, authenticate immediately with the new password</param>
66+
/// <returns>A task that completes when the password update finishes</returns>
67+
/// <exception cref="RequestException">Thrown when <paramref name="immediateAuth"/> is <c>true</c> and <paramref name="password"/> is <c>null</c></exception>
68+
public async Task UpdateConnectionPasswordAsync(string? password, bool immediateAuth = false)
69+
{
70+
Message message = MessageContainer.GetMessageForCall();
71+
IntPtr passwordPtr = (password == null) ? IntPtr.Zero : Marshal.StringToHGlobalAnsi(password);
72+
try
73+
{
74+
UpdateConnectionPasswordFfi(ClientPointer, (ulong)message.Index, passwordPtr, immediateAuth);
75+
IntPtr response = await message;
76+
try
77+
{
78+
HandleResponse(response);
79+
}
80+
finally
81+
{
82+
FreeResponse(response);
83+
}
84+
}
85+
finally
86+
{
87+
if (passwordPtr != IntPtr.Zero)
88+
{
89+
Marshal.FreeHGlobal(passwordPtr);
90+
}
91+
}
92+
}
6193
#endregion public methods
6294

6395
#region protected methods

0 commit comments

Comments
 (0)