Commit fa4d7d09 authored by Marc Gravell's avatar Marc Gravell

implement SWAPDB (#551)

parent c3c5234e
...@@ -152,6 +152,7 @@ internal enum RedisCommand ...@@ -152,6 +152,7 @@ internal enum RedisCommand
SUNION, SUNION,
SUNIONSTORE, SUNIONSTORE,
SSCAN, SSCAN,
SWAPDB,
SYNC, SYNC,
TIME, TIME,
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
...@@ -537,6 +537,18 @@ public partial interface IServer : IRedis ...@@ -537,6 +537,18 @@ public partial interface IServer : IRedis
/// <remarks>https://redis.io/commands/pubsub</remarks> /// <remarks>https://redis.io/commands/pubsub</remarks>
Task<long> SubscriptionSubscriberCountAsync(RedisChannel channel, CommandFlags flags = CommandFlags.None); Task<long> SubscriptionSubscriberCountAsync(RedisChannel channel, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Swaps two Redis databases, so that immediately all the clients connected to a given database will see the data of the other database, and the other way around
/// </summary>
/// <remarks>https://redis.io/commands/swapdb</remarks>
void SwapDatabases(int first, int second, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Swaps two Redis databases, so that immediately all the clients connected to a given database will see the data of the other database, and the other way around
/// </summary>
/// <remarks>https://redis.io/commands/swapdb</remarks>
Task SwapDatabasesAsync(int first, int second, CommandFlags flags = CommandFlags.None);
/// <summary> /// <summary>
/// The TIME command returns the current server time. /// The TIME command returns the current server time.
/// </summary> /// </summary>
...@@ -648,4 +660,4 @@ public partial interface IServer : IRedis ...@@ -648,4 +660,4 @@ public partial interface IServer : IRedis
#endregion #endregion
} }
} }
\ No newline at end of file
...@@ -182,6 +182,7 @@ public bool IsAdmin ...@@ -182,6 +182,7 @@ public bool IsAdmin
case RedisCommand.SHUTDOWN: case RedisCommand.SHUTDOWN:
case RedisCommand.SLAVEOF: case RedisCommand.SLAVEOF:
case RedisCommand.SLOWLOG: case RedisCommand.SLOWLOG:
case RedisCommand.SWAPDB:
case RedisCommand.SYNC: case RedisCommand.SYNC:
return true; return true;
default: default:
...@@ -381,6 +382,7 @@ public static bool IsMasterOnly(RedisCommand command) ...@@ -381,6 +382,7 @@ public static bool IsMasterOnly(RedisCommand command)
case RedisCommand.SPOP: case RedisCommand.SPOP:
case RedisCommand.SREM: case RedisCommand.SREM:
case RedisCommand.SUNIONSTORE: case RedisCommand.SUNIONSTORE:
case RedisCommand.SWAPDB:
case RedisCommand.ZADD: case RedisCommand.ZADD:
case RedisCommand.ZINTERSTORE: case RedisCommand.ZINTERSTORE:
case RedisCommand.ZINCRBY: case RedisCommand.ZINCRBY:
......
...@@ -505,6 +505,18 @@ public Task<long> SubscriptionSubscriberCountAsync(RedisChannel channel, Command ...@@ -505,6 +505,18 @@ public Task<long> SubscriptionSubscriberCountAsync(RedisChannel channel, Command
return ExecuteAsync(msg, ResultProcessor.PubSubNumSub); return ExecuteAsync(msg, ResultProcessor.PubSubNumSub);
} }
public void SwapDatabases(int first, int second, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(-1, flags, RedisCommand.SWAPDB, first, second);
ExecuteSync(msg, ResultProcessor.DemandOK);
}
public Task SwapDatabasesAsync(int first, int second, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(-1, flags, RedisCommand.SWAPDB, first, second);
return ExecuteAsync(msg, ResultProcessor.DemandOK);
}
public DateTime Time(CommandFlags flags = CommandFlags.None) public DateTime Time(CommandFlags flags = CommandFlags.None)
{ {
var msg = Message.Create(-1, flags, RedisCommand.TIME); var msg = Message.Create(-1, flags, RedisCommand.TIME);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment