From 76bb8a9eb617edae050fb15cd5b0ace23ab8a562 Mon Sep 17 00:00:00 2001 From: Abdelrahman El Kinani Date: Fri, 19 Nov 2021 21:56:58 +0200 Subject: [PATCH] Replace Dictionary with ConcurrentDictionary (#2503) --- src/core/Elsa.Core/Persistence/InMemory/InMemoryStore.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/Elsa.Core/Persistence/InMemory/InMemoryStore.cs b/src/core/Elsa.Core/Persistence/InMemory/InMemoryStore.cs index b63ae77af..36f9b4aeb 100644 --- a/src/core/Elsa.Core/Persistence/InMemory/InMemoryStore.cs +++ b/src/core/Elsa.Core/Persistence/InMemory/InMemoryStore.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System.Collections.Concurrent; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -95,7 +96,7 @@ namespace Elsa.Persistence.InMemory return dictionary.Values.AsQueryable().FirstOrDefault(specification.ToExpression()); } - private async Task> GetDictionaryAsync() => await MemoryCache.GetOrCreateAsync(CacheKey, _ => Task.FromResult(new Dictionary())); + private async Task> GetDictionaryAsync() => await MemoryCache.GetOrCreateAsync(CacheKey, _ => Task.FromResult(new ConcurrentDictionary())); private void SetDictionary(IDictionary dictionary) => MemoryCache.Set(CacheKey, dictionary); } } \ No newline at end of file