Skip to content

Align and consolidate cache expiration settings across CacheService#1973

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/implement-issue-590
Draft

Align and consolidate cache expiration settings across CacheService#1973
Copilot wants to merge 2 commits intomainfrom
copilot/implement-issue-590

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

Cache durations across services were inconsistent—some cached for 12 hours, others for 1 hour, with no centralized policy. This consolidates all cache TTLs into four standardized tiers.

Centralized CacheDurations constants

New static class in core/Microsoft.Mcp.Core/src/Services/Caching/CacheDurations.cs:

Tier Duration Rationale
Tenant 12h Rarely changes
Subscription 2h Relatively stable
AuthenticatedClient 15min SDK client instances
ServiceData 5min User-facing resource data
// Before: each service defined its own ad-hoc duration
private static readonly TimeSpan s_cacheDuration = TimeSpan.FromHours(1);

// After: references centralized constant
private static readonly TimeSpan s_cacheDuration = CacheDurations.ServiceData;

Duration changes

  • SubscriptionService: 12h → 2h
  • ResourceGroupService, AksService, FunctionAppService, SignalRService: 1h → 5min
  • KustoService: data 1h → 5min, clients 2h → 15min
  • SearchService: services 1h → 5min (clients already 15min)
  • CosmosService: split single 15min duration into AuthenticatedClient (15min) for CosmosClient instances and ServiceData (5min) for database/container lists
  • TenantService: no value change, now references CacheDurations.Tenant

Tests

Added CacheDurationsTests validating all four tier values and their ordering.

Invoking Livetests

Copilot submitted PRs are not trustworthy by default. Users with write access to the repo need to validate the contents of this PR before leaving a comment with the text /azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • learn.microsoft.com
    • Triggering command: /home/REDACTED/work/mcp/mcp/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/bin/Debug/net10.0/Azure.Mcp.Core.UnitTests /home/REDACTED/work/mcp/mcp/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/bin/Debug/net10.0/Azure.Mcp.Core.UnitTests @@ /tmp/tmpgty3Y9.tmp grep -l ICacheService ice.cs /usr/bin/grep (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Create centralized CacheDurations class with standardized durations:
- Tenant: 12 hours (unchanged)
- Subscription: 2 hours (was 12 hours)
- AuthenticatedClient: 15 minutes
- ServiceData: 5 minutes (was 1 hour or 15 minutes)

Update all services to reference centralized constants:
- TenantService, SubscriptionService, ResourceGroupService
- AksService, CosmosService, FunctionAppService
- KustoService, SearchService, SignalRService

Fixes #590

Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement feature from issue 590 Align and consolidate cache expiration settings across CacheService Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants