-
Notifications
You must be signed in to change notification settings - Fork 524
[Client encryption] Add distributed cache support to DEK caching #5428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adamnova
wants to merge
13
commits into
Azure:master
Choose a base branch
from
adamnova:feature/introduce-distributed-cache
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Client encryption] Add distributed cache support to DEK caching #5428
adamnova
wants to merge
13
commits into
Azure:master
from
adamnova:feature/introduce-distributed-cache
Conversation
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
Introduces distributed cache integration in DekCache for cross-process/cross-instance caching of Data Encryption Key (DEK) properties. Adds proactive refresh capability and updates constructors to support distributed cache and refresh threshold options. Includes new tests for distributed cache scenarios and updates project dependencies for distributed caching.
Updated code and tests to replace terminology referring to L1 and L2 cache with memory cache and distributed cache for clarity. Refactored method and variable names accordingly in DekCache and related test cases.
Reworked DekCache to separate memory and distributed cache logic, ensuring distributed cache is used before fetching from source and updating all caches. Added best-effort distributed cache update and removal, and improved error handling to avoid failures if distributed cache operations fail. Updated tests to clear only memory cache for distributed cache validation.
- Changed SetDekProperties to use Task.Run for proper fire-and-forget pattern - Added Debug.WriteLine logging for distributed cache operations - Added null check in DeserializeCachedDekProperties to prevent NullReferenceException - Added exception handling with diagnostic logging in all catch blocks
…nd validation - Add ActivitySource telemetry with OpenTelemetry-compatible semantic tags - Track cache operations: hit/miss, latency, errors - Operations: GetOrAddProperties, FetchProperties, DistributedCacheRead, UpdateDistributedCache - Tags: cache.system, cache.key, cache.hit, cache.miss, cache.latency_ms, etc. - Add configurable cache key prefix parameter (default: 'dek') - Enables multi-tenant scenarios with shared distributed cache - Non-breaking change with sensible default - Validated using ArgumentValidation.ThrowIfNullOrWhiteSpace - Add ArgumentValidation helper methods for TimeSpan - ThrowIfNegative(TimeSpan) - validates non-negative TimeSpan values - ThrowIfGreaterThanOrEqual(TimeSpan, TimeSpan) - validates TimeSpan comparison - Consistent with existing int overloads - 15 new unit tests for TimeSpan validation methods - Document race condition in SetDekProperties with comprehensive XML comments - Explains fire-and-forget pattern and eventual consistency - Details mitigation strategies and when it matters - Provides guidance for strict consistency scenarios - All validation using ArgumentValidation helpers for consistency - Replaced inline validation with helper methods - Updated exception types: ArgumentException -> ArgumentOutOfRangeException where appropriate Test coverage: - 32/32 DekCache tests passing (16 unique × 2 frameworks) - 94/94 ArgumentValidation tests passing (47 unique × 2 frameworks) - All builds successful across netstandard2.0, net6.0, net8.0
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.
Introduces distributed cache integration in DekCache for cross-process/cross-instance caching of Data Encryption Key (DEK) properties. Adds proactive refresh capability and updates constructors to support distributed cache and refresh threshold options. Includes new tests for distributed cache scenarios and updates project dependencies for distributed caching.
#4678