From 98ab7e9c6e6cd15865d0811bbeadfcc017d9b165 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 12 Oct 2022 18:18:04 +0200 Subject: [PATCH] Fix rules cache duration parameter. --- .../HandleRules/RuleOptions.cs | 2 +- .../src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs | 7 ++++++- backend/tests/docker-compose.yml | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleOptions.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleOptions.cs index 029b3a292..15211f0ac 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleOptions.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleOptions.cs @@ -11,6 +11,6 @@ namespace Squidex.Domain.Apps.Core.HandleRules { public int ExecutionTimeoutInSeconds { get; set; } = 3; - public TimeSpan RuleCacheDuration { get; set; } = TimeSpan.FromSeconds(10); + public TimeSpan RulesCacheDuration { get; set; } = TimeSpan.FromSeconds(10); } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs index e18b1da43..f06ce5108 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs @@ -42,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Rules { this.appProvider = appProvider; this.cache = cache; - this.cacheDuration = options.Value.RuleCacheDuration; + this.cacheDuration = options.Value.RulesCacheDuration; this.ruleEventRepository = ruleEventRepository; this.ruleService = ruleService; this.log = log; @@ -98,6 +98,11 @@ namespace Squidex.Domain.Apps.Entities.Rules private Task> GetRulesAsync(DomainId appId) { + if (cacheDuration <= TimeSpan.Zero || cacheDuration == TimeSpan.MaxValue) + { + return appProvider.GetRulesAsync(appId); + } + var cacheKey = $"{typeof(RuleEnqueuer)}_Rules_{appId}"; // Cache the rules for performance reasons for a short period of time (usually 10 sec). diff --git a/backend/tests/docker-compose.yml b/backend/tests/docker-compose.yml index 24d96bf6c..46052e98b 100644 --- a/backend/tests/docker-compose.yml +++ b/backend/tests/docker-compose.yml @@ -44,6 +44,7 @@ services: - IDENTITY__ADMINCLIENTID=root - IDENTITY__ADMINCLIENTSECRET=xeLd6jFxqbXJrfmNLlO2j1apagGGGSyZJhFnIuHp4I0= - IDENTITY__MULTIPLEDOMAINS=true + - RULES__RULESCACHEDURATION=00:00:00 - SCRIPTING__TIMEOUTEXECUTION=00:00:10 - SCRIPTING__TIMEOUTSCRIPT=00:00:10 - STORE__MONGODB__CONFIGURATION=mongodb://mongo