Skip to content

Conversation

@adamnova
Copy link
Contributor

@adamnova adamnova commented Oct 1, 2025

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

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
@adamnova adamnova marked this pull request as ready for review October 2, 2025 07:13
…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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant