diff --git a/src/NRedisStack/Search/ISearchCommands.cs b/src/NRedisStack/Search/ISearchCommands.cs index 2d9e090b..a63f473f 100644 --- a/src/NRedisStack/Search/ISearchCommands.cs +++ b/src/NRedisStack/Search/ISearchCommands.cs @@ -67,6 +67,7 @@ public interface ISearchCommands /// is name of the configuration option, or '*' for all. /// An array reply of the configuration name and value. /// + [Obsolete("Starting from Redis 8.0, use db.ConfigGet instead")] Dictionary ConfigGet(string option); /// @@ -76,6 +77,7 @@ public interface ISearchCommands /// is value of the configuration option. /// if executed correctly, error otherwise. /// + [Obsolete("Starting from Redis 8.0, use db.ConfigSet instead")] bool ConfigSet(string option, string value); /// diff --git a/src/NRedisStack/Search/ISearchCommandsAsync.cs b/src/NRedisStack/Search/ISearchCommandsAsync.cs index 0e1e7333..b3047892 100644 --- a/src/NRedisStack/Search/ISearchCommandsAsync.cs +++ b/src/NRedisStack/Search/ISearchCommandsAsync.cs @@ -66,6 +66,7 @@ public interface ISearchCommandsAsync /// is name of the configuration option, or '*' for all. /// An array reply of the configuration name and value. /// + [Obsolete("Starting from Redis 8.0, use db.ConfigGetAsync instead")] Task> ConfigGetAsync(string option); /// @@ -75,6 +76,7 @@ public interface ISearchCommandsAsync /// is value of the configuration option. /// if executed correctly, error otherwise. /// + [Obsolete("Starting from Redis 8.0, use db.ConfigSetAsync instead")] Task ConfigSetAsync(string option, string value); /// diff --git a/src/NRedisStack/Search/SearchCommandBuilder.cs b/src/NRedisStack/Search/SearchCommandBuilder.cs index 1d962a96..696983ee 100644 --- a/src/NRedisStack/Search/SearchCommandBuilder.cs +++ b/src/NRedisStack/Search/SearchCommandBuilder.cs @@ -47,11 +47,13 @@ public static SerializedCommand Alter(string index, Schema schema, bool skipInit return new SerializedCommand(FT.ALTER, args); } + [Obsolete("Starting from Redis 8.0, use db.ConfigGet instead")] public static SerializedCommand ConfigGet(string option) { return new SerializedCommand(FT.CONFIG, "GET", option); } + [Obsolete("Starting from Redis 8.0, use db.ConfigSet instead")] public static SerializedCommand ConfigSet(string option, string value) { return new SerializedCommand(FT.CONFIG, "SET", option, value); diff --git a/src/NRedisStack/Search/SearchCommands.cs b/src/NRedisStack/Search/SearchCommands.cs index 409ba24b..ea42e2ee 100644 --- a/src/NRedisStack/Search/SearchCommands.cs +++ b/src/NRedisStack/Search/SearchCommands.cs @@ -51,12 +51,14 @@ public bool Alter(string index, Schema schema, bool skipInitialScan = false) } /// + [Obsolete("Starting from Redis 8.0, use db.ConfigGet instead")] public Dictionary ConfigGet(string option) { return _db.Execute(SearchCommandBuilder.ConfigGet(option)).ToConfigDictionary(); } /// + [Obsolete("Starting from Redis 8.0, use db.ConfigSet instead")] public bool ConfigSet(string option, string value) { return _db.Execute(SearchCommandBuilder.ConfigSet(option, value)).OKtoBoolean(); diff --git a/src/NRedisStack/Search/SearchCommandsAsync.cs b/src/NRedisStack/Search/SearchCommandsAsync.cs index 2ed0080d..7dcd25b7 100644 --- a/src/NRedisStack/Search/SearchCommandsAsync.cs +++ b/src/NRedisStack/Search/SearchCommandsAsync.cs @@ -83,12 +83,14 @@ public async Task AlterAsync(string index, Schema schema, bool skipInitial } /// + [Obsolete("Starting from Redis 8.0, use db.ConfigGetAsync instead")] public async Task> ConfigGetAsync(string option) { return (await _db.ExecuteAsync(SearchCommandBuilder.ConfigGet(option))).ToConfigDictionary(); } /// + [Obsolete("Starting from Redis 8.0, use db.ConfigSetAsync instead")] public async Task ConfigSetAsync(string option, string value) { return (await _db.ExecuteAsync(SearchCommandBuilder.ConfigSet(option, value))).OKtoBoolean(); diff --git a/tests/NRedisStack.Tests/CommunityEditionUpdatesTests.cs b/tests/NRedisStack.Tests/CommunityEditionUpdatesTests.cs new file mode 100644 index 00000000..3d4dd0ab --- /dev/null +++ b/tests/NRedisStack.Tests/CommunityEditionUpdatesTests.cs @@ -0,0 +1,113 @@ +using StackExchange.Redis; +using Xunit; + +namespace NRedisStack.Tests; + +public class CommunityEditionUpdatesTests : AbstractNRedisStackTest, IDisposable +{ + public CommunityEditionUpdatesTests(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } + + private IServer getAnyPrimary(IConnectionMultiplexer muxer) + { + foreach (var endpoint in muxer.GetEndPoints()) + { + var server = muxer.GetServer(endpoint); + if (!server.IsReplica) return server; + } + throw new InvalidOperationException("Requires a primary endpoint (found none)"); + } + + [SkipIfRedis(Comparison.LessThan, "7.9.0")] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ConfigSearchSettings(string endpointId) + { + IDatabase db = GetCleanDatabase(endpointId); + IConnectionMultiplexer muxer = db.Multiplexer; + IServer server = getAnyPrimary(muxer); + + server.ConfigSet("search-on-timeout", "fail"); + + Assert.Equal("fail", server.ConfigGet("search-on-timeout").First().Value); + + server.ConfigSet("search-on-timeout", "return"); + + Assert.Single(server.ConfigGet("search-min-prefix")); + + Assert.Single(server.ConfigGet("search-max-prefix-expansions")); + + Assert.Single(server.ConfigGet("search-max-doctablesize")); + + Assert.Single(server.ConfigGet("search-max-search-results")); + + Assert.Single(server.ConfigGet("search-max-aggregate-results")); + + Assert.Single(server.ConfigGet("search-friso-ini")); + + Assert.Single(server.ConfigGet("search-default-dialect")); + } + + [SkipIfRedis(Comparison.LessThan, "7.9.0")] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ConfigTimeSeriesSettings(string endpointId) + { + IDatabase db = GetCleanDatabase(endpointId); + IConnectionMultiplexer muxer = db.Multiplexer; + IServer server = getAnyPrimary(muxer); + + Assert.Single(server.ConfigGet("ts-compaction-policy")); + + Assert.Single(server.ConfigGet("ts-retention-policy")); + + Assert.Single(server.ConfigGet("ts-duplicate-policy")); + + Assert.Single(server.ConfigGet("ts-encoding")); + + Assert.Single(server.ConfigGet("ts-chunk-size-bytes")); + + Assert.Single(server.ConfigGet("ts-ignore-max-time-diff")); + + Assert.Single(server.ConfigGet("ts-ignore-max-val-diff")); + } + + [SkipIfRedis(Comparison.LessThan, "7.9.0")] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ConfigProbabilisticSettings(string endpointId) + { + IDatabase db = GetCleanDatabase(endpointId); + IConnectionMultiplexer muxer = db.Multiplexer; + IServer server = getAnyPrimary(muxer); + + server.ConfigSet("bf-error-rate", "0.02"); + + Assert.Single(server.ConfigGet("bf-error-rate")); + + Assert.Equal("0.02", server.ConfigGet("bf-error-rate").First().Value); + + Assert.Single(server.ConfigGet("bf-initial-size")); + + Assert.Single(server.ConfigGet("cf-max-expansions")); + + Assert.Single(server.ConfigGet("bf-expansion-factor")); + + Assert.Single(server.ConfigGet("cf-expansion-factor")); + + Assert.Single(server.ConfigGet("cf-initial-size")); + + Assert.Single(server.ConfigGet("cf-bucket-size")); + + Assert.Single(server.ConfigGet("cf-max-iterations")); + } + + [SkipIfRedis(Comparison.LessThan, "7.9.0")] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void InfoSearchSection(string endpointId) + { + IDatabase db = GetCleanDatabase(endpointId); + IConnectionMultiplexer muxer = db.Multiplexer; + IServer server = getAnyPrimary(muxer); + + var searchInfo = server.Info("search"); + CustomAssertions.GreaterThan(10, searchInfo.Length); + } + +} \ No newline at end of file