Skip to content

Conversation

@brant-livefront
Copy link
Contributor

📔 Objective

As we expand usage of distributed caching, we discovered that the redis connection string is not enabled in all of our environments / containers. The current code defaults to a database-backed distributed cache if the Redis string is not available. While this is a sensible backup for self-hosted environments, it does not work well in the cloud environment.

This PR adds a check to ensure that self-hosted is true before adding the database distributed cache. In cloud, this will now add nothing. This is an acceptable outcome for cloud. The ExtendedCache service collection extension is calling TryWithRegisteredKeyedDistributedCache if the redis connection string is not set. This means that it will fail gracefully if there is no defined distributed cache - falling back to simply caching in memory (L1).

See the section in ExtendedCacheServiceCollectionExtensions.cs that starts at line 126 for more detail around this scenario. There's also a test: ExtendedCacheServiceCollectionExtensionsTests.AddExtendedCache_NoDistributedCacheRegistered_WorksWithMemoryOnly that explicitly tests for this scenario.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

Logo
Checkmarx One – Scan Summary & Details5dbf768d-2acf-4d88-a2af-32fcfbc845bf

Great job! No new security vulnerabilities introduced in this pull request

Copy link
Contributor

@withinfocus withinfocus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was transient, but there are test failures given cache resolution now.

@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

❌ Patch coverage is 7.14286% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.72%. Comparing base (f82552f) to head (776787f).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...SharedWeb/Utilities/ServiceCollectionExtensions.cs 7.14% 12 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6783      +/-   ##
==========================================
- Coverage   54.84%   54.72%   -0.12%     
==========================================
  Files        1920     1920              
  Lines       85255    85261       +6     
  Branches     7633     7634       +1     
==========================================
- Hits        46757    46659      -98     
- Misses      36718    36830     +112     
+ Partials     1780     1772       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@withinfocus withinfocus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't foresee this to ever be used in practice for our cloud but it can be in place for fallbacks when configs don't exist as expected.

@brant-livefront brant-livefront merged commit cc03842 into main Dec 31, 2025
64 of 66 checks passed
@brant-livefront brant-livefront deleted the brant/disable-cloud-database-cache branch December 31, 2025 17:00
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.

3 participants