Skip to content

Commit 3d43209

Browse files
author
Nick Craver
committed
Merge branch 'main' into pr/1585
2 parents 0d5e7c9 + a774cd1 commit 3d43209

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+919
-83
lines changed

.github/workflows/Linux.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ on:
1010
- '!/docs/*' # Don't run workflow when files are only in the /docs directory
1111

1212
jobs:
13-
build:
14-
name: Ubuntu
13+
main:
14+
name: StackExchange.Redis (Ubuntu)
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout code
@@ -21,9 +21,25 @@ jobs:
2121
- name: Start Redis Services
2222
working-directory: ./tests/RedisConfigs
2323
run: docker-compose -f docker-compose.yml up -d
24-
- name: .NET Test
25-
run: dotnet test Build.csproj -c Release --no-build /p:CI=true
26-
env:
27-
EnableTestLogging: true
24+
- name: StackExchange.Redis.Tests
25+
run: dotnet test tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj -c Release --logger GitHubActions /p:CI=true
2826
- name: .NET Lib Pack
29-
run: dotnet pack Build.csproj --no-build -c Release /p:Packing=true /p:PackageOutputPath=%CD%\.nupkgs /p:CI=true
27+
run: dotnet pack src/StackExchange.Redis/StackExchange.Redis.csproj --no-build -c Release /p:Packing=true /p:PackageOutputPath=%CD%\.nupkgs /p:CI=true
28+
29+
nredisearch:
30+
name: NRediSearch (Ubuntu)
31+
runs-on: ubuntu-latest
32+
services:
33+
redisearch:
34+
image: redislabs/redisearch:latest
35+
ports:
36+
- 6385:6379
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v1
40+
- name: .NET Build
41+
run: dotnet build Build.csproj -c Release /p:CI=true
42+
- name: NRedisSearch.Tests
43+
run: dotnet test tests/NRediSearch.Test/NRediSearch.Test.csproj -c Release --logger GitHubActions /p:CI=true
44+
- name: .NET Lib Pack
45+
run: dotnet pack src/NRediSearch/NRediSearch.csproj --no-build -c Release /p:Packing=true /p:PackageOutputPath=%CD%\.nupkgs /p:CI=true

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
3636
</ItemGroup>
3737
<ItemGroup>
38-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.1.91" PrivateAssets="all" />
38+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="all" />
3939
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all"/>
4040
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="all" />
4141
</ItemGroup>

Directory.Build.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
</ItemGroup>
99
<ItemGroup>
1010
<PackageReference Update="BenchmarkDotNet" Version="0.12.0" />
11+
<PackageReference Update="GitHubActionsTestLogger" Version="1.1.0" />
1112
<PackageReference Update="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" />
12-
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.6.1" />
13+
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.7.0" />
1314
<PackageReference Update="Moq" Version="4.14.1" />
1415
<PackageReference Update="NSubstitute" Version="4.2.1" />
1516
<PackageReference Update="Pipelines.Sockets.Unofficial" Version="2.1.16" />

StackExchange.Redis.sln

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RedisConfigs", "RedisConfig
3131
tests\RedisConfigs\start-basic.sh = tests\RedisConfigs\start-basic.sh
3232
tests\RedisConfigs\start-cluster.cmd = tests\RedisConfigs\start-cluster.cmd
3333
tests\RedisConfigs\start-sentinel.cmd = tests\RedisConfigs\start-sentinel.cmd
34+
tests\RedisConfigs\wsl2.md = tests\RedisConfigs\wsl2.md
3435
EndProjectSection
3536
EndProject
3637
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchange.Redis", "src\StackExchange.Redis\StackExchange.Redis.csproj", "{EF84877F-59BE-41BE-9013-E765AF0BB72E}"
@@ -71,8 +72,8 @@ EndProject
7172
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Basic", "Basic", "{38BDEEED-7BEB-4B1F-9CE0-256D63F9C502}"
7273
ProjectSection(SolutionItems) = preProject
7374
tests\RedisConfigs\Basic\master-6379.conf = tests\RedisConfigs\Basic\master-6379.conf
75+
tests\RedisConfigs\Basic\replica-6380.conf = tests\RedisConfigs\Basic\replica-6380.conf
7476
tests\RedisConfigs\Basic\secure-6381.conf = tests\RedisConfigs\Basic\secure-6381.conf
75-
tests\RedisConfigs\Basic\slave-6380.conf = tests\RedisConfigs\Basic\slave-6380.conf
7677
EndProjectSection
7778
EndProject
7879
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicTestBaseline", "tests\BasicTestBaseline\BasicTestBaseline.csproj", "{8FDB623D-779B-4A84-BC6B-75106E41D8A4}"
@@ -82,7 +83,7 @@ EndProject
8283
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Failover", "Failover", "{D082703F-1652-4C35-840D-7D377F6B9979}"
8384
ProjectSection(SolutionItems) = preProject
8485
tests\RedisConfigs\Failover\master-6382.conf = tests\RedisConfigs\Failover\master-6382.conf
85-
tests\RedisConfigs\Failover\slave-6383.conf = tests\RedisConfigs\Failover\slave-6383.conf
86+
tests\RedisConfigs\Failover\replica-6383.conf = tests\RedisConfigs\Failover\replica-6383.conf
8687
EndProjectSection
8788
EndProject
8889
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchange.Redis.Server", "toys\StackExchange.Redis.Server\StackExchange.Redis.Server.csproj", "{8375813E-FBAF-4DA3-A2C7-E4645B39B931}"
@@ -134,6 +135,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{A9F81D
134135
tests\RedisConfigs\Docker\supervisord.conf = tests\RedisConfigs\Docker\supervisord.conf
135136
EndProjectSection
136137
EndProject
138+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RediSearch", "RediSearch", "{3FA2A7C6-DA16-4DEF-ACE0-34573A4AD430}"
139+
ProjectSection(SolutionItems) = preProject
140+
tests\RedisConfigs\RediSearch\redisearch-6385.conf = tests\RedisConfigs\RediSearch\redisearch-6385.conf
141+
tests\RedisConfigs\RediSearch\redisearch.md = tests\RedisConfigs\RediSearch\redisearch.md
142+
EndProjectSection
143+
EndProject
137144
Global
138145
GlobalSection(SolutionConfigurationPlatforms) = preSolution
139146
Debug|Any CPU = Debug|Any CPU
@@ -206,6 +213,7 @@ Global
206213
{153A10E4-E668-41AD-9E0F-6785CE7EED66} = {3AD17044-6BFF-4750-9AC2-2CA466375F2A}
207214
{D58114AE-4998-4647-AFCA-9353D20495AE} = {E25031D3-5C64-430D-B86F-697B66816FD8}
208215
{A9F81DA3-DA82-423E-A5DD-B11C37548E06} = {96E891CD-2ED7-4293-A7AB-4C6F5D8D2B05}
216+
{3FA2A7C6-DA16-4DEF-ACE0-34573A4AD430} = {96E891CD-2ED7-4293-A7AB-4C6F5D8D2B05}
209217
EndGlobalSection
210218
GlobalSection(ExtensibilityGlobals) = postSolution
211219
SolutionGuid = {193AA352-6748-47C1-A5FC-C9AA6B5F000B}

appveyor.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
image:
22
- Visual Studio 2019
3-
- Ubuntu
43

54
init:
65
- git config --global core.autocrlf input
76

8-
services:
9-
- docker
10-
117
install:
128
- cmd: >-
139
cd tests\RedisConfigs\3.0.503
@@ -45,18 +41,6 @@ install:
4541
redis-server.exe --service-install --service-name "redis-26381" "..\Sentinel\sentinel-26381.conf" --sentinel
4642
4743
cd ..\..\..
48-
- sh: >-
49-
sudo curl -L https://github.com/docker/compose/releases/download/1.26.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
50-
51-
sudo chmod +x /usr/local/bin/docker-compose
52-
53-
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
54-
55-
cd tests/RedisConfigs
56-
57-
docker-compose up -d
58-
59-
cd ../..
6044
- ps: >-
6145
if (Get-Command "Start-Service" -errorAction SilentlyContinue) {
6246
Start-Service redis-*

src/NRediSearch/NRediSearch.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
44
<GenerateDocumentationFile>false</GenerateDocumentationFile>
55
<PackageTags>Redis;Search;Modules;RediSearch</PackageTags>
66
<SignAssembly>true</SignAssembly>

src/NRediSearch/Query.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public NumericFilter(string property, double min, double max) : this(property, m
4646

4747
internal override void SerializeRedisArgs(List<object> args)
4848
{
49-
RedisValue FormatNum(double num, bool exclude)
49+
static RedisValue FormatNum(double num, bool exclude)
5050
{
5151
if (!exclude || double.IsInfinity(num))
5252
{

src/NRediSearch/Schema.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal Field(string name, FieldType type, bool sortable, bool noIndex = false)
3636

3737
internal virtual void SerializeRedisArgs(List<object> args)
3838
{
39-
object GetForRedis(FieldType type)
39+
static object GetForRedis(FieldType type)
4040
{
4141
switch (type)
4242
{

src/StackExchange.Redis/ClusterConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ internal ClusterNode(ClusterConfiguration configuration, string raw, EndPoint or
316316
{
317317
if (SlotRange.TryParse(parts[i], out SlotRange range))
318318
{
319-
(slots ?? (slots = new List<SlotRange>(parts.Length - i))).Add(range);
319+
(slots ??= new List<SlotRange>(parts.Length - i)).Add(range);
320320
}
321321
}
322322
Slots = slots?.AsReadOnly() ?? (IList<SlotRange>)Array.Empty<SlotRange>();
@@ -336,7 +336,7 @@ public IList<ClusterNode> Children
336336
{
337337
if (node.ParentNodeId == NodeId)
338338
{
339-
(nodes ?? (nodes = new List<ClusterNode>())).Add(node);
339+
(nodes ??= new List<ClusterNode>()).Add(node);
340340
}
341341
}
342342
children = nodes?.AsReadOnly() ?? (IList<ClusterNode>)Array.Empty<ClusterNode>();

src/StackExchange.Redis/CommandMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ internal CommandMap(CommandBytes[] map)
7272
/// <remarks>https://redis.io/topics/sentinel</remarks>
7373
public static CommandMap Sentinel { get; } = Create(new HashSet<string> {
7474
// see https://redis.io/topics/sentinel
75-
"auth", "ping", "info", "sentinel", "subscribe", "shutdown", "psubscribe", "unsubscribe", "punsubscribe" }, true);
75+
"auth", "ping", "info", "role", "sentinel", "subscribe", "shutdown", "psubscribe", "unsubscribe", "punsubscribe" }, true);
7676

7777
/// <summary>
7878
/// Create a new CommandMap, customizing some commands

src/StackExchange.Redis/ConfigurationOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ public bool PreserveAsyncOrder
335335
/// <summary>
336336
/// The retry policy to be used for connection reconnects
337337
/// </summary>
338-
public IReconnectRetryPolicy ReconnectRetryPolicy { get { return reconnectRetryPolicy ?? (reconnectRetryPolicy = new LinearRetry(ConnectTimeout)); } set { reconnectRetryPolicy = value; } }
338+
public IReconnectRetryPolicy ReconnectRetryPolicy { get { return reconnectRetryPolicy ??= new LinearRetry(ConnectTimeout); } set { reconnectRetryPolicy = value; } }
339339

340340
/// <summary>
341341
/// Indicates whether endpoints should be resolved via DNS before connecting.
342-
/// If enabled the ConnectionMultiplexer will re-resolve DNS
342+
/// If enabled the ConnectionMultiplexer will not re-resolve DNS
343343
/// when attempting to re-connect after a connection failure.
344344
/// </summary>
345345
public bool ResolveDns { get { return resolveDns.GetValueOrDefault(); } set { resolveDns = value; } }

src/StackExchange.Redis/ConnectionMultiplexer.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ public ServerCounters GetCounters()
143143
private static string defaultClientName;
144144
private static string GetDefaultClientName()
145145
{
146-
return defaultClientName ?? (defaultClientName = TryGetAzureRoleInstanceIdNoThrow()
146+
return defaultClientName ??= TryGetAzureRoleInstanceIdNoThrow()
147147
?? Environment.MachineName
148148
?? Environment.GetEnvironmentVariable("ComputerName")
149-
?? "StackExchange.Redis");
149+
?? "StackExchange.Redis";
150150
}
151151

152152
/// <summary>
@@ -1428,9 +1428,9 @@ public IDatabase GetDatabase(int db = -1, object asyncState = null)
14281428
// different instances, one of which (arbitrarily) ends up cached for later use
14291429
if (db == 0)
14301430
{
1431-
return dbCacheZero ?? (dbCacheZero = new RedisDatabase(this, 0, null));
1431+
return dbCacheZero ??= new RedisDatabase(this, 0, null);
14321432
}
1433-
var arr = dbCacheLow ?? (dbCacheLow = new IDatabase[MaxCachedDatabaseInstance]);
1433+
var arr = dbCacheLow ??= new IDatabase[MaxCachedDatabaseInstance];
14341434
return arr[db - 1] ?? (arr[db - 1] = new RedisDatabase(this, db, null));
14351435
}
14361436

@@ -1741,7 +1741,7 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, LogP
17411741
}
17421742
}
17431743

1744-
watch = watch ?? Stopwatch.StartNew();
1744+
watch ??= Stopwatch.StartNew();
17451745
var remaining = RawConfig.ConnectTimeout - checked((int)watch.ElapsedMilliseconds);
17461746
log?.WriteLine($"Allowing endpoints {TimeSpan.FromMilliseconds(remaining)} to respond...");
17471747
Trace("Allowing endpoints " + TimeSpan.FromMilliseconds(remaining) + " to respond...");
@@ -2402,7 +2402,7 @@ public ConnectionMultiplexer GetSentinelMasterConnection(ConfigurationOptions co
24022402

24032403
// verify role is master according to:
24042404
// https://redis.io/topics/sentinel-clients
2405-
if (connection.GetServer(newMasterEndPoint)?.Role() == RedisLiterals.master)
2405+
if (connection.GetServer(newMasterEndPoint)?.Role().Value == RedisLiterals.master)
24062406
{
24072407
success = true;
24082408
break;
@@ -2542,13 +2542,9 @@ internal void SwitchMaster(EndPoint switchBlame, ConnectionMultiplexer connectio
25422542

25432543
// Get new master - try twice
25442544
EndPoint newMasterEndPoint = GetConfiguredMasterForService(serviceName)
2545-
?? GetConfiguredMasterForService(serviceName);
2546-
2547-
if (newMasterEndPoint == null)
2548-
{
2549-
throw new RedisConnectionException(ConnectionFailureType.UnableToConnect,
2550-
$"Sentinel: Failed connecting to switch master for service: {serviceName}");
2551-
}
2545+
?? GetConfiguredMasterForService(serviceName)
2546+
?? throw new RedisConnectionException(ConnectionFailureType.UnableToConnect,
2547+
$"Sentinel: Failed connecting to switch master for service: {serviceName}");
25522548

25532549
connection.currentSentinelMasterEndPoint = newMasterEndPoint;
25542550

@@ -2904,6 +2900,14 @@ public Task<long> PublishReconfigureAsync(CommandFlags flags = CommandFlags.None
29042900
/// </summary>
29052901
/// <param name="key">The <see cref="RedisKey"/> to determine the hash slot for.</param>
29062902
public int GetHashSlot(RedisKey key) => ServerSelectionStrategy.HashSlot(key);
2903+
2904+
internal void MarkServerEndpointsForReplicationRoleRefresh()
2905+
{
2906+
foreach (var s in servers.Values)
2907+
{
2908+
((ServerEndPoint)s).ForceReplicationCheck = true;
2909+
}
2910+
}
29072911
}
29082912

29092913
internal enum WriteResult

src/StackExchange.Redis/Enums/RedisCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ internal enum RedisCommand
122122
RENAMENX,
123123
REPLICAOF,
124124
RESTORE,
125+
ROLE,
125126
RPOP,
126127
RPOPLPUSH,
127128
RPUSH,

src/StackExchange.Redis/Format.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ internal static EndPoint TryParseEndPoint(string addressWithPort)
229229
// Link: https://github.com/aspnet/BasicMiddleware/blob/f320511b63da35571e890d53f3906c7761cd00a1/src/Microsoft.AspNetCore.HttpOverrides/Internal/IPEndPointParser.cs#L8
230230
// Copyright (c) .NET Foundation. All rights reserved.
231231
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
232-
string addressPart = null;
232+
string addressPart;
233233
string portPart = null;
234234
if (string.IsNullOrEmpty(addressWithPort)) return null;
235235

src/StackExchange.Redis/Interfaces/IDatabase.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,18 @@ public interface IDatabase : IRedis, IDatabaseAsync
651651
/// <remarks>https://redis.io/commands/lpushx</remarks>
652652
long ListLeftPush(RedisKey key, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None);
653653

654+
/// <summary>
655+
/// Insert the specified value at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations.
656+
/// </summary>
657+
/// <param name="key">The key of the list.</param>
658+
/// <param name="values">The values to add to the head of the list.</param>
659+
/// <param name="when">Which conditions to add to the list under (defaults to always).</param>
660+
/// <param name="flags">The flags to use for this operation.</param>
661+
/// <returns>The length of the list after the push operations.</returns>
662+
/// <remarks>https://redis.io/commands/lpush</remarks>
663+
/// <remarks>https://redis.io/commands/lpushx</remarks>
664+
long ListLeftPush(RedisKey key, RedisValue[] values, When when = When.Always, CommandFlags flags = CommandFlags.None);
665+
654666
/// <summary>
655667
/// Insert all the specified values at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations.
656668
/// Elements are inserted one after the other to the head of the list, from the leftmost element to the rightmost element. So for instance the command LPUSH mylist a b c will result into a list containing c as first element, b as second element and a as third element.
@@ -729,6 +741,18 @@ public interface IDatabase : IRedis, IDatabaseAsync
729741
/// <remarks>https://redis.io/commands/rpushx</remarks>
730742
long ListRightPush(RedisKey key, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None);
731743

744+
/// <summary>
745+
/// Insert the specified value at the tail of the list stored at key. If key does not exist, it is created as empty list before performing the push operation.
746+
/// </summary>
747+
/// <param name="key">The key of the list.</param>
748+
/// <param name="values">The values to add to the tail of the list.</param>
749+
/// <param name="when">Which conditions to add to the list under.</param>
750+
/// <param name="flags">The flags to use for this operation.</param>
751+
/// <returns>The length of the list after the push operation.</returns>
752+
/// <remarks>https://redis.io/commands/rpush</remarks>
753+
/// <remarks>https://redis.io/commands/rpushx</remarks>
754+
long ListRightPush(RedisKey key, RedisValue[] values, When when = When.Always, CommandFlags flags = CommandFlags.None);
755+
732756
/// <summary>
733757
/// Insert all the specified values at the tail of the list stored at key. If key does not exist, it is created as empty list before performing the push operation.
734758
/// Elements are inserted one after the other to the tail of the list, from the leftmost element to the rightmost element. So for instance the command RPUSH mylist a b c will result into a list containing a as first element, b as second element and c as third element.

0 commit comments

Comments
 (0)