Skip to content

Commit d186c2c

Browse files
committed
Move internal caches inititalization into constructor
1 parent 290e27e commit d186c2c

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

Orm/Xtensive.Orm/Orm/StorageNode.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,29 @@ public sealed class StorageNode : ISessionSource
5050
/// <summary>
5151
/// Caches providers that lock certain type of entity with certain <see cref="LockMode"/> and <see cref="LockBehavior"/>.
5252
/// </summary>
53-
internal ConcurrentDictionary<(TypeInfo, LockMode, LockBehavior), ExecutableProvider> EntityLockProviderCache { get; } =
54-
new ConcurrentDictionary<(TypeInfo, LockMode, LockBehavior), ExecutableProvider>();
53+
internal ConcurrentDictionary<(TypeInfo, LockMode, LockBehavior), ExecutableProvider> EntityLockProviderCache { get; }
5554

5655
/// <summary>
5756
/// Caches uncompiled queries used by <see cref="PrefetchManager"/> to fetch certain entities.
5857
/// </summary>
59-
internal ConcurrentDictionary<RecordSetCacheKey, CompilableProvider> EntityFetchQueryCache { get; } =
60-
new ConcurrentDictionary<RecordSetCacheKey, CompilableProvider>();
58+
internal ConcurrentDictionary<RecordSetCacheKey, CompilableProvider> EntityFetchQueryCache { get; }
6159

6260
/// <summary>
6361
/// Caches uncompiled queries used by <see cref="PrefetchManager"/> to fetch <see cref="EntitySet{TItem}"/> content.
6462
/// </summary>
65-
internal ConcurrentDictionary<ItemsQueryCacheKey, CompilableProvider> EntitySetFetchQueryCache { get; } =
66-
new ConcurrentDictionary<ItemsQueryCacheKey, CompilableProvider>();
63+
internal ConcurrentDictionary<ItemsQueryCacheKey, CompilableProvider> EntitySetFetchQueryCache { get; }
6764

6865
/// <summary>
6966
/// Caches certain info about EntitySet fields, e.g. queries to fetch current count or items.
7067
/// </summary>
71-
internal ConcurrentDictionary<Xtensive.Orm.Model.FieldInfo, EntitySetTypeState> EntitySetTypeStateCache { get; } =
72-
new ConcurrentDictionary<Xtensive.Orm.Model.FieldInfo, EntitySetTypeState>();
68+
internal ConcurrentDictionary<Xtensive.Orm.Model.FieldInfo, EntitySetTypeState> EntitySetTypeStateCache { get; }
7369

7470
/// <summary>
7571
/// Caches queries that get references to entities for certain association.
7672
/// </summary>
77-
internal ConcurrentDictionary<AssociationInfo, (CompilableProvider, Parameter<Xtensive.Tuples.Tuple>)> RefsToEntityQueryCache { get; } =
78-
new ConcurrentDictionary<AssociationInfo, (CompilableProvider, Parameter<Xtensive.Tuples.Tuple>)>();
79-
80-
internal ConcurrentDictionary<SequenceInfo, object> KeySequencesCache { get; } = new ConcurrentDictionary<SequenceInfo, object>();
81-
73+
internal ConcurrentDictionary<AssociationInfo, (CompilableProvider, Parameter<Xtensive.Tuples.Tuple>)> RefsToEntityQueryCache { get; }
74+
internal ConcurrentDictionary<SequenceInfo, object> KeySequencesCache { get; }
8275
internal ConcurrentDictionary<PersistRequestBuilderTask, ICollection<PersistRequest>> PersistRequestCache { get; }
83-
= new ConcurrentDictionary<PersistRequestBuilderTask, ICollection<PersistRequest>>();
8476

8577
/// <inheritdoc/>
8678
public Session OpenSession()
@@ -149,6 +141,14 @@ internal StorageNode(Domain domain, NodeConfiguration configuration, ModelMappin
149141
ArgumentValidator.EnsureArgumentNotNull(mapping, nameof(mapping));
150142
ArgumentValidator.EnsureArgumentNotNull(typeIdRegistry, nameof(typeIdRegistry));
151143

144+
EntityLockProviderCache = new ConcurrentDictionary<(TypeInfo, LockMode, LockBehavior), ExecutableProvider>();
145+
EntityFetchQueryCache = new ConcurrentDictionary<RecordSetCacheKey, CompilableProvider>();
146+
EntitySetFetchQueryCache = new ConcurrentDictionary<ItemsQueryCacheKey, CompilableProvider>();
147+
EntitySetTypeStateCache = new ConcurrentDictionary<Xtensive.Orm.Model.FieldInfo, EntitySetTypeState>();
148+
RefsToEntityQueryCache = new ConcurrentDictionary<AssociationInfo, (CompilableProvider, Parameter<Xtensive.Tuples.Tuple>)>();
149+
KeySequencesCache = new ConcurrentDictionary<SequenceInfo, object>();
150+
PersistRequestCache = new ConcurrentDictionary<PersistRequestBuilderTask, ICollection<PersistRequest>>();
151+
152152
this.domain = domain;
153153
Configuration = configuration;
154154
Mapping = mapping;

0 commit comments

Comments
 (0)