diff --git a/Orm/Xtensive.Orm/Orm/StorageNode.cs b/Orm/Xtensive.Orm/Orm/StorageNode.cs index fc130bceb..32500270d 100644 --- a/Orm/Xtensive.Orm/Orm/StorageNode.cs +++ b/Orm/Xtensive.Orm/Orm/StorageNode.cs @@ -4,11 +4,7 @@ // Created by: Denis Krjuchkov // Created: 2014.03.13 -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; +using BitFaster.Caching.Lru; using Xtensive.Core; using Xtensive.Orm.Configuration; using Xtensive.Orm.Interfaces; @@ -26,6 +22,8 @@ namespace Xtensive.Orm /// public sealed class StorageNode : ISessionSource { + private const int CacheCapacity = 256; + private readonly Domain domain; /// @@ -51,29 +49,29 @@ public sealed class StorageNode : ISessionSource /// /// Caches providers that lock certain type of entity with certain and . /// - internal ConcurrentDictionary<(TypeInfo, LockMode, LockBehavior), ExecutableProvider> EntityLockProviderCache { get; } = new(); + internal FastConcurrentLru<(TypeInfo, LockMode, LockBehavior), ExecutableProvider> EntityLockProviderCache { get; } = new(CacheCapacity); /// /// Caches uncompiled queries used by to fetch certain entities. /// - internal ConcurrentDictionary EntityFetchQueryCache { get; } = new(); + internal FastConcurrentLru EntityFetchQueryCache { get; } = new(CacheCapacity); /// /// Caches uncompiled queries used by to fetch content. /// - internal ConcurrentDictionary EntitySetFetchQueryCache { get; } = new(); + internal FastConcurrentLru EntitySetFetchQueryCache { get; } = new(CacheCapacity); /// /// Caches certain info about EntitySet fields, e.g. queries to fetch current count or items. /// - internal ConcurrentDictionary EntitySetTypeStateCache { get; } = new(); + internal FastConcurrentLru EntitySetTypeStateCache { get; } = new(CacheCapacity); /// /// Caches queries that get references to entities for certain association. /// - internal ConcurrentDictionary)> RefsToEntityQueryCache { get; } = new(); - internal ConcurrentDictionary KeySequencesCache { get; } = new(); - internal ConcurrentDictionary> PersistRequestCache { get; } = new(); + internal FastConcurrentLru)> RefsToEntityQueryCache { get; } = new(CacheCapacity); + internal FastConcurrentLru KeySequencesCache { get; } = new(CacheCapacity); + internal FastConcurrentLru> PersistRequestCache { get; } = new(CacheCapacity); /// public Session OpenSession() => @@ -115,8 +113,8 @@ public Task OpenSessionAsync(SessionConfiguration configuration, Cancel public void ClearSequenceCaches() { - foreach (var seq in KeySequencesCache.Values) { - seq.Reset(); + foreach (var (_, v) in KeySequencesCache) { + v.Reset(); } }