Repository navigation
Add in-memory value buffer caching for entity types - #565
Merged
masesdevelopers merged 3 commits intoApr 8, 2026
Merged
masesdevelopers merged 3 commits into
masesdevelopers merged 3 commits into
Conversation
Introduce per-entity in-memory caching for full enumeration of value buffers. Adds KEFCoreValueBufferCacheAttribute and a KEFCoreValueBufferCacheConvention to read the attribute at model finalization and store TTL annotations (ValueBufferCacheTtl, ValueBufferReverseCacheTtl). Exposes builder and IEntityType helpers (HasKEFCoreValueBufferCache, GetValueBufferCacheTtl, GetValueBufferReverseCacheTtl). Implements CachedValueBufferEnumerable in EntityTypeProducer to populate and serve a list on first full enumeration and invalidate caches on commit; supports separate forward/reverse TTL and disables caching when TTL is zero. Wire the convention into KEFCoreConventionSetBuilder.
| if (prefixComponents == null) | ||
| { | ||
| // simple key â treat as string prefix if applicable | ||
| return key is string s && prefixComponents != null; // no-op for simple keys |
Comment on lines
+37
to
+49
| foreach (var entityType in modelBuilder.Metadata.GetEntityTypes()) | ||
| { | ||
| if (entityType.ClrType.GetCustomAttributes(typeof(KEFCoreValueBufferCacheAttribute), inherit: false) | ||
| .FirstOrDefault() is not KEFCoreValueBufferCacheAttribute attr) continue; | ||
|
|
||
| var builder = (IConventionEntityTypeBuilder)entityType.Builder; | ||
|
|
||
| if (attr.Ttl > TimeSpan.Zero) | ||
| builder.HasAnnotation(KEFCoreAnnotationNames.ValueBufferCacheTtl, attr.Ttl); | ||
|
|
||
| if (attr.ReverseTtl > TimeSpan.Zero) | ||
| builder.HasAnnotation(KEFCoreAnnotationNames.ValueBufferReverseCacheTtl, attr.ReverseTtl); | ||
| } |
Comment on lines
+363
to
+367
| foreach (var kv in cache) | ||
| { | ||
| if (MatchesPrefix(kv.Key, prefixComponents, prefixLength, properties)) | ||
| result.Add(kv.Value); | ||
| } |
masesdevelopers
deleted the
564-add-cache-behavior-side-by-side-with-backend-retrieve-methods
branch
April 8, 2026 16:43
masesdevelopers
added a commit
that referenced
this pull request
Apr 18, 2026
masesdevelopers
added a commit
that referenced
this pull request
Apr 21, 2026
* Moved future management for transactional producers * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> * Fix wrong serializer set in #570 * Fix #565 * Update test program to report errors in case of failure * Update trademark symbol * Cleanup --------- Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduce per-entity in-memory caching for full enumeration of value buffers. Adds KEFCoreValueBufferCacheAttribute and a KEFCoreValueBufferCacheConvention to read the attribute at model finalization and store TTL annotations (ValueBufferCacheTtl, ValueBufferReverseCacheTtl). Exposes builder and IEntityType helpers (HasKEFCoreValueBufferCache, GetValueBufferCacheTtl, GetValueBufferReverseCacheTtl). Implements CachedValueBufferEnumerable in EntityTypeProducer to populate and serve a list on first full enumeration and invalidate caches on commit; supports separate forward/reverse TTL and disables caching when TTL is zero. Wire the convention into KEFCoreConventionSetBuilder.
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: