Skip to content

Add Support to 'SCRIPT KILL' Command #2158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
10 changes: 10 additions & 0 deletions src/StackExchange.Redis/Interfaces/IServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,16 @@ public partial interface IServer : IRedis
/// <inheritdoc cref="ScriptLoad(LuaScript, CommandFlags)"/>
Task<LoadedLuaScript> ScriptLoadAsync(LuaScript script, CommandFlags flags = CommandFlags.None);

/// <summary>
/// Kills the currently executing EVAL script.
/// </summary>
/// <param name="flags">The command flags to use.</param>
/// <remarks><seealso href="https://redis.io/commands/script-kill/"/></remarks>
void ScriptKill(CommandFlags flags = CommandFlags.None);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I would expect a string response based on the docs - is that not the case here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted the line from the documentation, I looked at the similar command: 'ScriptFlush' and there it was done this way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shacharPash Sorry should have been clearer: I meant in the Redis server documentation, it returns a string so we should return it here :)


/// <inheritdoc cref="ScriptKill(CommandFlags)"/>
Task ScriptKillAsync(CommandFlags flags = CommandFlags.None);

/// <summary>
/// Asks the redis server to shutdown, killing all connections. Please FULLY read the notes on the <c>SHUTDOWN</c> command.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/StackExchange.Redis/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,8 @@ StackExchange.Redis.IServer.ScriptLoad(StackExchange.Redis.LuaScript! script, St
StackExchange.Redis.IServer.ScriptLoad(string! script, StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> byte[]!
StackExchange.Redis.IServer.ScriptLoadAsync(StackExchange.Redis.LuaScript! script, StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Threading.Tasks.Task<StackExchange.Redis.LoadedLuaScript!>!
StackExchange.Redis.IServer.ScriptLoadAsync(string! script, StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Threading.Tasks.Task<byte[]!>!
StackExchange.Redis.IServer.ScriptKill(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> void
StackExchange.Redis.IServer.ScriptKillAsync(StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Threading.Tasks.Task!
StackExchange.Redis.IServer.SentinelFailover(string! serviceName, StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> void
StackExchange.Redis.IServer.SentinelFailoverAsync(string! serviceName, StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Threading.Tasks.Task!
StackExchange.Redis.IServer.SentinelGetMasterAddressByName(string! serviceName, StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Net.EndPoint?
Expand Down
12 changes: 12 additions & 0 deletions src/StackExchange.Redis/RedisServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,18 @@ public Task<LoadedLuaScript> ScriptLoadAsync(LuaScript script, CommandFlags flag
return script.LoadAsync(this, flags);
}

public void ScriptKill(CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(-1, flags, RedisCommand.SCRIPT, RedisLiterals.KILL);
ExecuteSync(msg, ResultProcessor.DemandOK);
}

public Task ScriptKillAsync(CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(-1, flags, RedisCommand.SCRIPT, RedisLiterals.KILL);
return ExecuteAsync(msg, ResultProcessor.DemandOK);
}

public void Shutdown(ShutdownMode shutdownMode = ShutdownMode.Default, CommandFlags flags = CommandFlags.None)
{
Message msg = shutdownMode switch
Expand Down