Reduce CacheEntry size (#45962)
authorAdam Sitnik <adam.sitnik@gmail.com>
Thu, 7 Jan 2021 19:57:33 +0000 (20:57 +0100)
committerGitHub <noreply@github.com>
Thu, 7 Jan 2021 19:57:33 +0000 (20:57 +0100)
commit533a807b74c3b9258bb5355eb94c7fb48918f4b9
treefcd8856828cb9ffd7939305ab369aed8e5abd80a
parent35e935441c4c88611b6635cbf4a0f482cbad863c
Reduce CacheEntry size (#45962)

* reduce the size of CacheEntry instance by 2xsizeof(int)

* remove _lock field and use "this" for locking instead

* move _expirationTokenRegistrations, _postEvictionCallbacks and _expirationTokens to separate type to reduce the typical cache entry size

* apply code review suggestion: don't use Enum.HasFlag

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
* Apply suggestions from code review

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
src/libraries/Microsoft.Extensions.Caching.Memory/src/CacheEntry.CacheEntryState.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.Caching.Memory/src/CacheEntry.CacheEntryTokens.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.Caching.Memory/src/CacheEntry.cs
src/libraries/Microsoft.Extensions.Caching.Memory/tests/CacheEntryScopeExpirationTests.cs