Commit fa4d7d09 authored by Marc Gravell's avatar Marc Gravell

implement SWAPDB (#551)

parent c3c5234e
......@@ -152,6 +152,7 @@ internal enum RedisCommand
SUNION,
SUNIONSTORE,
SSCAN,
SWAPDB,
SYNC,
TIME,
......
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
......@@ -537,6 +537,18 @@ public partial interface IServer : IRedis
/// <remarks>https://redis.io/commands/pubsub</remarks>
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>
/// The TIME command returns the current server time.
/// </summary>
......
......@@ -182,6 +182,7 @@ public bool IsAdmin
case RedisCommand.SHUTDOWN:
case RedisCommand.SLAVEOF:
case RedisCommand.SLOWLOG:
case RedisCommand.SWAPDB:
case RedisCommand.SYNC:
return true;
default:
......@@ -381,6 +382,7 @@ public static bool IsMasterOnly(RedisCommand command)
case RedisCommand.SPOP:
case RedisCommand.SREM:
case RedisCommand.SUNIONSTORE:
case RedisCommand.SWAPDB:
case RedisCommand.ZADD:
case RedisCommand.ZINTERSTORE:
case RedisCommand.ZINCRBY:
......
......@@ -505,6 +505,18 @@ public Task<long> SubscriptionSubscriberCountAsync(RedisChannel channel, Command
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)
{
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