diff --git a/README.md b/README.md index bd7a0a3e3..781c06035 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Web application to help schools plan a technology roadmap ## Requirements -- .Net 8.0 and any supported IDE for DEV running. +- .Net 8.0 and any supported IDE for DEV running. ## Running Locally diff --git a/src/Dfe.PlanTech.Infrastructure.Redis/RedisDependencyManager.cs b/src/Dfe.PlanTech.Infrastructure.Redis/RedisDependencyManager.cs index e360484b4..3e36afa5b 100644 --- a/src/Dfe.PlanTech.Infrastructure.Redis/RedisDependencyManager.cs +++ b/src/Dfe.PlanTech.Infrastructure.Redis/RedisDependencyManager.cs @@ -27,12 +27,16 @@ public Task RegisterDependenciesAsync(IDatabase database, string key, T value private async Task GetAndSetDependencies(IDatabase database, string key, T value) { var batch = database.CreateBatch(); - var tasks = GetDependencies(value).Select(dependency => batch.SetAddAsync(GetDependencyKey(dependency), key, CommandFlags.FireAndForget)).ToArray(); + var tasks = GetDependencies(value).Distinct() + .Select(dependency => batch.SetAddAsync(GetDependencyKey(dependency), key, CommandFlags.FireAndForget)) + .ToArray(); + if (tasks.Length == 0) { // If the value has no dependencies (is empty) it should be invalidated when new content comes in tasks = tasks.Append(batch.SetAddAsync(EmptyCollectionDependencyKey, key, CommandFlags.FireAndForget)).ToArray(); } + batch.Execute(); await Task.WhenAll(tasks); }