Skip to content

Commit 3de225e

Browse files
committed
prefer HashCode when possible
1 parent 45d31b3 commit 3de225e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Caching/Hybrid/src/Internal/DefaultHybridCache.StampedeKey.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ public StampedeKey(string key, HybridCacheEntryFlags flags)
1717
{
1818
_key = key;
1919
_flags = flags;
20+
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
21+
_hashCode = HashCode.Combine(key, flags);
22+
#else
2023
_hashCode = key.GetHashCode() ^ (int)flags;
24+
#endif
2125
}
2226

2327
public string Key => _key;

src/Caching/Hybrid/src/Microsoft.Extensions.Caching.Hybrid.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Description>Multi-level caching implementation building on and extending IDistributedCache</Description>
55
<!--
66
relevant TFM feature summary (all "nice to have", with reasonable workarounds):
7-
nca 2.0 / ns 2.1: RuntimeHelpers.IsReferenceOrContainsReferences; Task.IsCompletedSuccessfully
7+
nca 2.0 / ns 2.1: RuntimeHelpers.IsReferenceOrContainsReferences; Task.IsCompletedSuccessfully; HashCode
88
nca 3.0 : IThreadPoolWorkItem
99
net 5.0 : [DynamicallyAccessedMembers], EncodingExtensions.GetString/GetBytes, IsExternalInit
1010
net 7.0 : ArgumentNullException.ThrowIfNull

0 commit comments

Comments
 (0)