Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sources/Valkey.Glide/Abstract/ConnectionMultiplexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static async Task<ConnectionMultiplexer> ConnectAsync(ConfigurationOption
Utils.Requires<NotImplementedException>(log == null, "Log writer is not supported by GLIDE");
StandaloneClientConfiguration standaloneConfig = CreateClientConfigBuilder<StandaloneClientConfigurationBuilder>(configuration).Build();
GlideClient standalone = await GlideClient.CreateClient(standaloneConfig);
string info = await standalone.Info([Section.CLUSTER]);
string info = await standalone.InfoAsync([Section.CLUSTER]);
BaseClientConfiguration config = info.Contains("cluster_enabled:1")
? CreateClientConfigBuilder<ClusterClientConfigurationBuilder>(configuration).Build()
: standaloneConfig;
Expand Down
6 changes: 3 additions & 3 deletions sources/Valkey.Glide/Abstract/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace Valkey.Glide;

internal class Database : GlideClient, IDatabase
{
public new async Task<string> Info() => await Info([]);
public new async Task<string> InfoAsync() => await InfoAsync([]);

public new async Task<string> Info(InfoOptions.Section[] sections)
public new async Task<string> InfoAsync(InfoOptions.Section[] sections)
=> IsCluster
? await Command(Request.Info(sections), Route.Random)
: await base.Info(sections);
: await base.InfoAsync(sections);

public IBatch CreateBatch(object? asyncState = null)
{
Expand Down
83 changes: 80 additions & 3 deletions sources/Valkey.Glide/Abstract/IServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ public interface IServer
/// <inheritdoc cref="InfoRawAsync(ValkeyValue, CommandFlags)"/>
string? InfoRaw(ValkeyValue section = default, CommandFlags flags = CommandFlags.None);

/// <inheritdoc cref="InfoAsync(ValkeyValue, CommandFlags)"/>
IGrouping<string, KeyValuePair<string, string>>[] Info(ValkeyValue section = default, CommandFlags flags = CommandFlags.None);

/// <summary>
/// This command is often used to test if a connection is still alive, or to measure latency.
/// </summary>
Expand Down Expand Up @@ -131,6 +128,86 @@ public interface IServer
/// </remarks>
Task<ValkeyValue> EchoAsync(ValkeyValue message, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Get the values of configuration parameters.
/// </summary>
/// <seealso href="https://valkey.io/commands/config-get"/>
/// <param name="pattern">The pattern to match configuration parameters. If not specified, returns all parameters.</param>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
/// <returns>An array of key-value pairs representing configuration parameters and their values.</returns>
Task<KeyValuePair<string, string>[]> ConfigGetAsync(ValkeyValue pattern = default, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Reset the statistics reported by the INFO command.
/// </summary>
/// <seealso href="https://valkey.io/commands/config-resetstat"/>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
Task ConfigResetStatisticsAsync(CommandFlags flags = CommandFlags.None);

/// <summary>
/// Rewrite the configuration file with the current configuration.
/// </summary>
/// <seealso href="https://valkey.io/commands/config-rewrite"/>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
Task ConfigRewriteAsync(CommandFlags flags = CommandFlags.None);

/// <summary>
/// Set a configuration parameter to the given value.
/// </summary>
/// <seealso href="https://valkey.io/commands/config-set"/>
/// <param name="setting">The configuration parameter to set.</param>
/// <param name="value">The value to set for the configuration parameter.</param>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
Task ConfigSetAsync(ValkeyValue setting, ValkeyValue value, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Return the number of keys in the selected database.
/// </summary>
/// <seealso href="https://valkey.io/commands/dbsize"/>
/// <param name="database">The database index. If -1, uses the current database.</param>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
/// <returns>The number of keys in the database.</returns>
Task<long> DatabaseSizeAsync(int database = -1, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Delete all the keys of all databases on the server.
/// </summary>
/// <seealso href="https://valkey.io/commands/flushall"/>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
Task FlushAllDatabasesAsync(CommandFlags flags = CommandFlags.None);

/// <summary>
/// Delete all the keys of the selected database.
/// </summary>
/// <seealso href="https://valkey.io/commands/flushdb"/>
/// <param name="database">The database index. If -1, uses the current database.</param>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
Task FlushDatabaseAsync(int database = -1, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Return the UNIX timestamp of the last successful save to disk.
/// </summary>
/// <seealso href="https://valkey.io/commands/lastsave"/>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
/// <returns>The timestamp of the last successful save.</returns>
Task<DateTime> LastSaveAsync(CommandFlags flags = CommandFlags.None);

/// <summary>
/// Return the current server time.
/// </summary>
/// <seealso href="https://valkey.io/commands/time"/>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
/// <returns>The current server time.</returns>
Task<DateTime> TimeAsync(CommandFlags flags = CommandFlags.None);

/// <summary>
/// Display some computer art and the Valkey version.
/// </summary>
/// <seealso href="https://valkey.io/commands/lolwut"/>
/// <param name="flags">Command flags are not supported by GLIDE.</param>
/// <returns>A string containing computer art and version information.</returns>
Task<string> LolwutAsync(CommandFlags flags = CommandFlags.None);

/// <summary>
/// Gets the name of the current connection.
/// </summary>
Expand Down
63 changes: 60 additions & 3 deletions sources/Valkey.Glide/Abstract/ValkeyServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ public Task<IGrouping<string, KeyValuePair<string, string>>[]> InfoAsync(ValkeyV
public string? InfoRaw(ValkeyValue section = default, CommandFlags flags = CommandFlags.None)
=> InfoRawAsync(section, flags).GetAwaiter().GetResult();

public IGrouping<string, KeyValuePair<string, string>>[] Info(ValkeyValue section = default, CommandFlags flags = CommandFlags.None)
=> InfoAsync(section, flags).GetAwaiter().GetResult();

public async Task<TimeSpan> PingAsync(CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
Expand Down Expand Up @@ -101,4 +98,64 @@ public async Task<long> ClientIdAsync(CommandFlags flags = CommandFlags.None)
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
return await _conn.Command(Request.ClientId(), MakeRoute());
}

public async Task<KeyValuePair<string, string>[]> ConfigGetAsync(ValkeyValue pattern = default, CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
return await _conn.Command(Request.ConfigGetAsync(pattern), MakeRoute());
}

public async Task ConfigResetStatisticsAsync(CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
_ = await _conn.Command(Request.ConfigResetStatisticsAsync(), MakeRoute());
}

public async Task ConfigRewriteAsync(CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
_ = await _conn.Command(Request.ConfigRewriteAsync(), MakeRoute());
}

public async Task ConfigSetAsync(ValkeyValue setting, ValkeyValue value, CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
_ = await _conn.Command(Request.ConfigSetAsync(setting, value), MakeRoute());
}

public async Task<long> DatabaseSizeAsync(int database = -1, CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
return await _conn.Command(Request.DatabaseSizeAsync(database), MakeRoute());
}

public async Task FlushAllDatabasesAsync(CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
_ = await _conn.Command(Request.FlushAllDatabasesAsync(), MakeRoute());
}

public async Task FlushDatabaseAsync(int database = -1, CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
_ = await _conn.Command(Request.FlushDatabaseAsync(database), MakeRoute());
}

public async Task<DateTime> LastSaveAsync(CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
return await _conn.Command(Request.LastSaveAsync(), MakeRoute());
}

public async Task<DateTime> TimeAsync(CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
return await _conn.Command(Request.TimeAsync(), MakeRoute());
}

public async Task<string> LolwutAsync(CommandFlags flags = CommandFlags.None)
{
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
return await _conn.Command(Request.LolwutAsync(), MakeRoute());
}
}
Loading
Loading