Skip to content

Commit bb21e6f

Browse files
committed
Apply shared cache options in the RemoveNode method
1 parent 9400340 commit bb21e6f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Orm/Xtensive.Orm/Orm/StorageNodeManager.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,22 @@ public async Task<bool> AddNodeAsync([NotNull] NodeConfiguration configuration,
5252
/// </summary>
5353
/// <param name="nodeId">Node identifier.</param>
5454
/// <param name="clearQueryCache">
55-
/// if <see langword="true"/> then cached queries dedicated to the removing node will be removed from cache as well. By default <see langword="false"/>.
55+
/// If <see langword="true"/> then cached queries dedicated to the removing node will be removed from cache as well. By default <see langword="false"/>.
56+
/// Also note, that this parameter has no effect in case when both <see cref="DomainConfiguration.ShareStorageSchemaOverNodes"/>
57+
/// and <see cref="DomainConfiguration.PreferTypeIdsAsQueryParameters"/> options are turned on because cache will contain one
58+
/// item for all storage node instead of copies of same query per each storage node.
5659
/// </param>
5760
/// <returns>True if node was removed, otherwise false.</returns>
5861
public bool RemoveNode([NotNull] string nodeId, bool clearQueryCache = false)
5962
{
6063
var removeResult = handlers.StorageNodeRegistry.Remove(nodeId);
6164

6265
if (removeResult && clearQueryCache) {
66+
var domainConfig = handlers.Domain.Configuration;
67+
if (domainConfig.ShareStorageSchemaOverNodes && domainConfig.PreferTypeIdsAsQueryParameters) {
68+
return removeResult;
69+
}
70+
6371
var queryCache = (Caching.FastConcurrentLruCache<object, Pair<object, Linq.ParameterizedQuery>>) handlers.Domain.QueryCache;
6472
foreach (var key in queryCache.Keys.Where(k => k is Pair<object, string> pair && pair.Second == nodeId).ToChainedBuffer()) {
6573
queryCache.RemoveKey(key);

0 commit comments

Comments
 (0)