Commit b18dce52 authored by liuqiyun's avatar liuqiyun Committed by Nick Craver

add a command sentinels (#899)

* 新加scan,sentinels命令

* add command sentinels
parent 8cc645dc
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
......@@ -321,7 +321,7 @@ public partial interface IServer : IRedis
/// <remarks>https://redis.io/commands/keys</remarks>
/// <remarks>https://redis.io/commands/scan</remarks>
IEnumerable<RedisKey> Keys(int database = 0, RedisValue pattern = default(RedisValue), int pageSize = RedisBase.CursorUtils.DefaultPageSize, long cursor = RedisBase.CursorUtils.Origin, int pageOffset = 0, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Return the time of the last DB save executed with success. A client may check if a BGSAVE command succeeded reading the LASTSAVE value, then issuing a BGSAVE command and checking at regular intervals every N seconds if LASTSAVE changed.
/// </summary>
......@@ -646,6 +646,25 @@ public partial interface IServer : IRedis
/// <remarks>https://redis.io/topics/sentinel</remarks>
Task SentinelFailoverAsync(string serviceName, CommandFlags flags = CommandFlags.None);
/// <summary>
/// show a list of sentinels info about a redis master
/// </summary>
/// <param name="serviceName">The sentinel service name.</param>
/// <param name="flags">The command flags to use.</param>
/// <returns>an array of sentinel info KeyValuePair arrays</returns>
/// <remarks>https://redis.io/topics/sentinel</remarks>
KeyValuePair<string, string>[][] SentinelSentinels(string serviceName, CommandFlags flags = CommandFlags.None);
/// <summary>
/// show a list of sentinels info about a redis master
/// </summary>
/// <param name="serviceName">The sentinel service name.</param>
/// <param name="flags">The command flags to use.</param>
/// <returns>an array of sentinel info KeyValuePair arrays</returns>
/// <remarks>https://redis.io/topics/sentinel</remarks>
Task<KeyValuePair<string, string>[][]> SentinelSentinelsAsync(string serviceName, CommandFlags flags = CommandFlags.None);
#endregion
}
}
\ No newline at end of file
}
using System;
using System;
using System.Text;
namespace StackExchange.Redis
......@@ -66,6 +66,7 @@ public static readonly RedisValue
GETMASTERADDRBYNAME = "GET-MASTER-ADDR-BY-NAME",
// RESET = "RESET",
FAILOVER = "FAILOVER",
Sentinels = "Sentinels",
// Sentinel Literals as of 2.8.4
MONITOR = "MONITOR",
......@@ -104,4 +105,4 @@ internal static RedisValue Get(Bitwise operation)
}
}
}
}
\ No newline at end of file
}
......@@ -301,6 +301,7 @@ public IEnumerable<RedisKey> Keys(int database = 0, RedisValue pattern = default
Message msg = Message.Create(database, flags, RedisCommand.KEYS, pattern);
return ExecuteSync(msg, ResultProcessor.RedisKeyArray);
}
public DateTime LastSave(CommandFlags flags = CommandFlags.None)
{
......@@ -749,7 +750,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
}
}
}
#region Sentinel
public EndPoint SentinelGetMasterAddressByName(string serviceName, CommandFlags flags = CommandFlags.None)
......@@ -812,6 +813,19 @@ public Task SentinelFailoverAsync(string serviceName, CommandFlags flags = Comma
return ExecuteAsync(msg, ResultProcessor.SentinelArrayOfArrays);
}
public KeyValuePair<string, string>[][] SentinelSentinels(string serviceName, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(-1, flags, RedisCommand.SENTINEL, RedisLiterals.Sentinels, (RedisValue)serviceName);
return ExecuteSync(msg, ResultProcessor.SentinelArrayOfArrays);
}
public Task<KeyValuePair<string, string>[][]> SentinelSentinelsAsync(string serviceName, CommandFlags flags = CommandFlags.None)
{
var msg = Message.Create(-1, flags, RedisCommand.SENTINEL, RedisLiterals.Sentinels, (RedisValue)serviceName);
return ExecuteAsync(msg, ResultProcessor.SentinelArrayOfArrays);
}
#endregion
}
}
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