↑↓ to navigate Enter to open "…" all these words ANDOR to combine

Architecture Decision Record

ADR-026: Two-Tier Caching: a Swappable ICacheService Substrate plus an HTTP Output-Cache Edge

Status

Accepted (2026-06-27, amended 2026-07-10, 2026-07-23, 2026-07-25, 2026-08-14). Amended by ADR-077 (2026-08-13): Tier 1's substrate gains a third, opt-in implementation (HybridCacheService, L1 plus L2) writing under a disjoint hc: keyspace. The default path is unchanged; see the Revision (2026-08-13) below. Revised 2026-08-18: Tier 2 stops being per-process. An OutputCacheEvictionRequested integration event lets a mutation in one service evict another service's output cache over the existing outbox, broker and inbox path, per tag and best-effort, on a new MMCA.Common.OutputCache meter. Tier 1 is untouched by that change, which is the mirror image of ADR-077's Tier-1-only amendment; see the Revision (2026-08-18) at the end. Revised 2026-08-23: the counter trade-off now records that ICacheService's own <remarks> still anticipates a Redis INCR override that no implementation provides, so a reader who starts at the interface is not left with the opposite conclusion; anchors re-verified throughout. Amended 2026-09-01: an optional third tier on the client is recorded, IUiReadCache, a per-circuit read-through cache over the API client whose keys are the relative URL (path plus the full query) so they line up with Tier 2's QueryKeys = "*" policy. It is shipped and DI-registered, but opt-in per UI service and passed by no consumer app today; both server tiers are unchanged. See the Revision (2026-09-01) at the end. Revised 2026-09-03: the Redis wiring moved into the framework. All seven ADC and Store services reach Redis through MMCA.Common.Aspire's AddRedisCaching() / AddRedisOutputCaching() wrappers rather than Aspire's integrations directly, because the raw integrations register an untagged health check that gated readiness (ADR-025), and all seven also opt into ADR-077's HybridCacheService, so the memory-or-distributed auto-swap is the no-Redis path rather than the production one. Tier 2 gains a cache-bypassing-roles policy overload. See the Revision (2026-09-03) at the end. Revised 2026-09-07 (Tier-1 query cache keys carry the caller for a caller-scoped query, the public output-cache policy varies by resolved tenant and reads roles through the one shared helper, and the cache key prefix is namespaced per application by default). Revised 2026-09-25 (all seven services call both Redis wrappers unconditionally and reach AddCommonHybridCache() only when the redis connection string is configured, today through the framework's guarded AddCommonHybridCacheWhenRedisConfigured(...) helper; ADC Conference's bypass overload covers eleven of its twelve policies; the service and substrate anchors are refreshed). See the Revision (2026-09-25) at the end. Also revised 2026-07-24, 2026-07-28, 2026-08-01, 2026-08-07 and 2026-08-31 (substrate corrections and anchor refreshes; see those sections). Revised 2026-10-01 (the hybrid opt-in moved into the guarded framework helper AddCommonHybridCacheWhenRedisConfigured(...), and the client tier's store became generation-checked). See the Revision (2026-10-01) at the end. Revised 2026-10-06: the client tier invalidates after any write that may have landed, not only after a successful one, the default TTL is host-configurable through Cache:DefaultDuration, and ADC Conference's eleven-of-twelve count is scoped to its public-read policies beside the built-in ConferenceCache policy. See the Revision (2026-10-06) at the end. Revised 2026-10-07: with Redis configured, the 30-second local expiration is also the cross-replica backstop, because a HybridCacheService removal does not reach other replicas' L1 copies; anchors refreshed after the v1.233.0 release. Revised 2026-10-21: ICacheService's own comments now agree that no shipped IncrementAsync is atomic or uses Redis INCR, so the interface caveat is retired; all seven services declare a NoCache output-cache base, the two adopters included; the role-claim types are matched case-sensitively and only role values case-insensitively; anchors refreshed. Revised 2026-10-26: anchors refreshed after the v1.261.0 release and consumer sweep. Revised 2026-10-28: anchors refreshed after the v1.265.1 release and consumer sweep. Revised 2026-11-04 (Common v1.277.0): DistributedCacheService and RedisPrefixScanner are removed. HybridCacheService is the only shared-store substrate, prefix invalidation is one Redis write of a generation token instead of a keyspace SCAN, a non-empty prefix must end at : in every store, and resolving ICacheService throws when a distributed cache has no hybrid cache over it. The Decision and Trade-offs describe that state; the dated revisions below that name DistributedCacheService, RedisPrefixScanner or SCAN record the removed design as it stood on their date. See the Revision (2026-11-04) at the end. Amended 2026-11-17: the optional client tier is removed (MMCA.Common v1.301.0). IUiReadCache, UiReadCache and UiReadCacheOptions are deleted; the one consumer that adopted the tier withdrew it the same day after stale reads failed its end-to-end gate, and none adopted it since. Caching is two server tiers again, which is what this ADR always decided. The dated revisions that describe the client tier record it as it stood on their date. See the Revision (2026-11-17) at the end. Revised 2026-11-23: the Redis wrappers, the guarded hybrid helper and AddOutputCache with its NoCache base are called once by the composed service host (AddMmcaServiceHost) rather than by each service, the two output-cache adopters opt into the Redis store with UseRedisOutputCaching, Store Catalog has three public-read policies, ADC Conference bypasses ten of its eleven (one by permission too) beside a twelfth ConferenceCache policy, and anchors are refreshed; the eviction handler's 2026-08-18 non-reuse reason is recorded as contradicted by source (the API package already calls BestEffort). Revised 2026-11-30 (v1.324.0): the CQRS query cache that consumes this substrate is a host opt-in, AddQueryCaching(); without it IQueryCacheable and ICacheInvalidating are inert, so a host that caches no query results no longer pays a prefix bump and a delayed re-eviction on every write. The populate-lock wait defaults to five seconds instead of unbounded. The substrate and the output-cache edge are unchanged; see the Revision (2026-11-30) at the end. Revised 2026-12-03 (MMCA.Common v1.331.0): CacheOptions keeps only DefaultDuration; the entry-options default is removed and the stores apply the configured duration themselves. See the Revision (2026-12-03) at the end.

Context

The framework needs caching in two distinct places. Inside the application pipeline, query results are memoized and invalidated on mutation (the Caching decorators of ADR-014, keyed by IQueryCacheable / ICacheInvalidating), and a brute-force counter backs login protection (ADR-019). At the HTTP edge, public/anonymous read endpoints want their responses served without touching a handler at all. These two needs have different lifetimes, different invalidation models, and different failure tolerances, so a single cache primitive does not fit both.

The application-pipeline need also has to survive the monolith-to-services move (ADR-006/008): the same handler code runs in a single process (where an in-process cache is correct and cheapest) and in a scaled-out container app (where each replica's private memory cache would drift and a shared store is needed). We did not want handlers to know which deployment they are in.

This ADR records the caching decisions themselves. ADR-014 owns the decorator ordering and the marker interfaces; this ADR owns the substrate, the two tiers, and the invalidation semantics they sit on.

Decision

Cache in two tiers, each with its own substrate.

Tier 1: an application ICacheService substrate with a runtime memory-or-distributed swap

  • One abstraction. ICacheService (MMCA.Common.Application/Interfaces/ICacheService.cs) exposes GetAsync / SetAsync / RemoveAsync / RemoveByPrefixAsync. Application code (the ADR-014 Caching decorators, LoginProtectionService) depends only on this interface, never on a concrete cache or on Redis.
  • The backing store is chosen at startup, not in code (amended by ADR-077). AddCaching(configuration) (MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:30, where the configuration parameter is optional, called from AddInfrastructure at MMCA.Common.Infrastructure/DependencyInjection.cs:141) registers MemoryCacheService with TryAddSingleton (DependencyInjection.Caching.cs:79-99). The shared-store substrate is HybridCacheService (L1 in-process plus L2 distributed, ADR-077), registered by AddCommonHybridCache(...) (MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:162), which replaces the registration this call made (RemoveAll<ICacheService> at :188). A host that registers a real IDistributedCache (one that is not the in-memory MemoryDistributedCache) without that call does not fall back to memory: resolving ICacheService throws an InvalidOperationException naming AddCommonHybridCache (:89-92), because a silent in-process fallback would make single-use records, counters and the lockout flag per-replica (:81-85). The monolith with no distributed cache gets in-process caching for free; a host that wires Redis gets the shared store with no application-code change. This is the same "monolith now, scale or extract later" extension point as InProcessMessageBus vs BrokerMessageBus (ADR-003/006/008). AddCommonHybridCache, unlike the Redis wrappers in Trade-offs below, has no guard of its own, so the framework pairs it with a guarded helper, AddCommonHybridCacheWhenRedisConfigured(configuration, connectionName = "redis") (MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:226), which calls it only when the named connection string is non-empty (:232-235) and otherwise leaves the registration untouched. No service calls that helper itself: the composed service host does, once, for every service built on it (services.AddCommonHybridCacheWhenRedisConfigured(configuration), MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:95), and all seven ADC and Store services are built on it through builder.AddMmcaServiceHost(...): ADC Conference (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:82), Notification (.../MMCA.ADC.Notification.Service/Program.cs:58), Engagement (.../MMCA.ADC.Engagement.Service/Program.cs:58), Identity (.../MMCA.ADC.Identity.Service/Program.cs:82), Store Catalog (MMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:32), Sales (.../MMCA.Store.Sales.Service/Program.cs:51) and Identity (.../MMCA.Store.Identity.Service/Program.cs:37). So HybridCacheService is the live ICacheService wherever Redis is configured, and MemoryCacheService is what runs where it is not: local runs, tests, and any host that wires no Redis.
  • Prefix invalidation, implemented per store. IMemoryCache has no key-enumeration API, so MemoryCacheService tracks live keys in a ConcurrentDictionary (kept in sync by a post-eviction callback) to support RemoveByPrefixAsync. HybridCacheService never walks the keyspace: every : boundary of a key (the empty root, then each prefix ending at :) carries a generation token, the tokens in force are folded into the key an entry is stored under, and RemoveByPrefixAsync replaces one token, so every entry written under the old token stops being addressed on every replica and expires on its own TTL (MMCA.Common.Infrastructure/Caching/CachePrefixGenerations.cs:9-13). The invalidation is one Redis SET under {namespace}hcg:{prefix}, whatever the size of the keyspace (CachePrefixGenerations.cs:217-238, the write at :237, the key built at :281); when no IConnectionMultiplexer is registered the tokens live in the process, so the invalidation reaches that process only and is warned once (:224-231). Both stores enforce one argument contract: a prefix is empty or ends at a : boundary, otherwise ArgumentException (MMCA.Common.Infrastructure/Caching/CachePrefixContract.cs:17-27, called at MemoryCacheService.cs:146 and HybridCacheService.cs:335), the shape every ICacheInvalidating.CachePrefix takes (MMCA.Common.Application/Interfaces/ICacheService.cs:92-112).
  • A short default TTL bounds staleness. The 30 seconds is one figure with one home: CacheOptions.DefaultDuration (= TimeSpan.FromSeconds(30), MMCA.Common.Infrastructure/Caching/CacheOptions.cs:17), a bare TimeSpan and the only member of that static class, so every store, whatever its entry-options type, defaults to the same policy instead of hard-coding a second 30 seconds; callers may override per entry. A host may also move the default without code: CacheSettings.DefaultDuration (MMCA.Common.Infrastructure/Caching/CacheSettings.cs:41, the Cache:DefaultDuration key, at least one second :40) defaults to CacheOptions.DefaultDuration, is bound and validated at startup by AddCaching when it receives configuration (MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:53-56), and is what the cache services apply to an entry whose caller supplies no expiration (MemoryCacheService.cs:138, HybridCacheService.cs:410). The same section carries the memory store's entry limit (CacheSettings.cs:55), an optional L1 ceiling for HybridCacheService (:68, at least one second when set, :67) and the populate-lock timeout (:84). The short default means even a prefix invalidation that cannot reach every replica (memory mode, or the hybrid store without a multiplexer, where the generation tokens are process-local) self-heals within seconds. With Redis configured the bound is the local expiration: a single-key removal clears L2 and this process's L1, but other replicas' L1 copies keep serving the removed value until their local expiration lapses (MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:305-316), and a prefix invalidation reaches another replica once its remembered generation token expires, within the local duration plus one refresh round trip (MMCA.Common.Infrastructure/Caching/CachePrefixGenerations.cs:37-42). Both are bounded by Cache:LocalCacheDuration (30 seconds by default, HybridCacheService.cs:71; the L1 lifetime is the shorter of the entry TTL and that ceiling, WriteOptions at :458-469, the comparison at :466).

Tier 2: an HTTP output-cache edge

  • The pipeline always enables it; policies are opt-in per host. MMCA.Common.API calls app.UseOutputCache() in the shared middleware pipeline, which is a builder of named steps rather than a run of inline calls: the step is registered at MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:139-141 under the name MiddlewarePipelineStepNames.OutputCache (MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineStepNames.cs:71). The pipeline ships no policies. The composed service host registers AddOutputCache(...) once for every service built on it, with a NoCache base policy, then hands the options to the service's own ConfigureOutputCache callback (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:110-114, the base at :112), so all seven services carry the NoCache base and no service registers AddOutputCache itself. Identity, Sales, Engagement and Notification supply no callback, while the read-heavy public services add real cacheable named policies on top of that base (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:136, MMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:57). ADC Conference and Store Catalog are the adopters today, with named policies and [OutputCache] on their public read controllers.
  • Public-read policies cache authenticated requests too (amended by ADR-040). The framework UI attaches a Bearer token to every outgoing API request, including reads of [AllowAnonymous], user-independent endpoints, and ASP.NET Core's built-in default output-cache policy refuses to serve or store a cached response for any request carrying an Authorization header. So the adopters do not cache only anonymous traffic: they register their public-read policies through OutputCacheOptions.AddPublicEndpointPolicy(name, expiration, tags) (MMCA.Common.API/Caching/OutputCacheOptionsExtensions.cs:20), backed by PublicEndpointOutputCachePolicy (MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:47), whose CacheRequestAsync caches GET/HEAD regardless of the caller's auth state (MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:106-143, via the private helpers IsCacheableRequest / IsBypassedCaller at MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:165 and :172). ADC Conference and Store Catalog register these policies on their public read controllers; ADR-040 records that the built-in default policy served 0% of logged-in (bearer-carrying) traffic on conference day.
  • One adopter exempts a privileged role from the cache. AddPublicEndpointPolicy has a second overload taking cache-bypassing roles, AddPublicEndpointPolicy(name, expiration, bypassRoles, tags) (MMCA.Common.API/Caching/OutputCacheOptionsExtensions.cs:34): a caller in one of the named roles skips the cache entirely, no lookup and no storage, and always reads fresh. The policy class also takes a list of cache-bypassing permissions through a four-argument constructor (MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:92, the role check at :175 and the permission check at :188), which no AddPublicEndpointPolicy overload exposes, so a host that needs it registers the policy with the built-in AddPolicy(name, policy). Store Catalog's three policies use the plain overload and cache every caller alike (MMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:59-60, :64-65, :68-69). ADC Conference exempts privileged callers from ten of its eleven public-read policies, passing an adminBypassRoles array projected from ConferenceReadAudience.PrivilegedRoles (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:174), the same list the API layer's visibility checks read, because those roles receive an elevated payload (unpublished rows) that must never be stored under a key the public shares. Nine of the ten use the bypass overload (:175, :193-199 and :216); the tenth, the sessions policy (ConferenceCacheTags.SessionsPolicy), constructs the policy directly so it can also bypass a caller holding ConferencePermissions.SessionAssetsManage, because the session-assets read answers that permission with materials the public cannot see (:186-192, rationale :181-185). So "cache authenticated requests too" holds for the attendee and anonymous traffic that is the conference-day load, and stops at the privileged reader. The one public-read policy with no bypass list, NowNextCache (:202), returns the same payload to every role. Conference also registers a twelfth named policy, ConferenceCache, through the plain built-in AddPolicy (:143-144), not as a public-read policy: it keeps the built-in default semantics (no caching for an Authorization-carrying request) because a permission-gated controller also references it, and a public-read policy must never back a permission-gated endpoint (:138-142).
  • The output-cache store itself is Redis-backed wherever a service runs more than one replica. AddOutputCache defaults to a per-replica in-memory store, so a tag eviction reaches only the replica that served the mutation. Both adopters register a shared store through the framework wrapper builder.AddRedisOutputCaching() (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Caching/RedisCachingExtensions.cs:103), which holds the framework's single AddStackExchangeRedisOutputCache(...) call (:111) and no-ops when the named connection string is blank (:106-109). They reach it by setting the service-host option UseRedisOutputCaching = true (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/MmcaServiceHostOptions.cs:55), which the composed host checks before calling the wrapper (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:90-93): ADC Conference (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:129) and Store Catalog (MMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:53). No other service sets it. The adopters still lean on the wrapper's no-op where no Redis is configured. AddOutputCache registers its store with TryAdd, so the explicit registration wins regardless of call order, and with no Redis configured the in-memory store still applies, which is correct at a single replica. ADR-040's 2026-07-25 amendment makes the shared store the expected posture for any multi-replica deployment. The practical effect is that both tiers ride the same Redis instance: Tier 1 through IDistributedCache, Tier 2 through the output-cache store.

The client tier was removed (amended 2026-11-17)

From 2026-09-01 to 2026-11-17 the framework shipped an optional third tier, IUiReadCache, a per-circuit read-through cache over the API client keyed by the relative URL. It was opt-in per UI service through an optional EntityServiceBase constructor parameter, and it is gone as of MMCA.Common v1.301.0:

  • It failed the one adoption it had. Store opted all six of its UI services in with v1.175.0 and withdrew them the same day (Store #110): child-entity writes did not invalidate the parent's prefix (a variant edit re-read a stale product) and cross-service journeys (profile, checkout) read values up to 60 seconds old, which failed four end-to-end workflows and skipped the deploy. No consumer opted in afterwards.
  • What replaced it is a plain read. EntityServiceBase.SendGetAsync<T>(url, cancellationToken) (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Api/EntityServiceBase.cs:226) is the GET through the retry pipeline that the cache path wrapped; the former GetCachedAsync callers call it. The UiReadCache configuration section is ignored, and sign-out no longer has a client cache to clear.
  • Client-side staleness stays an application decision. A UI that needs to avoid re-reading hot reference data memoizes it in a purpose-built lookup service with its own invalidation (ADC's event and speaker lookups do), where the invalidation rules match the one read pattern they serve.

Rationale

  • One substrate, swapped by environment. Keeping ICacheService as the only thing application code sees lets the deployment decide memory vs distributed. The auto-swap (presence of a real IDistributedCache) means there is no flag to forget and no per-handler branching.
  • Two tiers because the jobs differ. Tier 1 memoizes handler results and invalidates them precisely on mutation (prefix/ICacheInvalidating). Tier 2 skips the handler entirely for public reads at the HTTP edge. It began as the anonymous-traffic lever ADR-019 leans on (anonymous callers are exempt from the per-user rate limiter, so output caching absorbs that load instead); as amended by ADR-040 the adopters' public-read policies now cache authenticated (bearer-carrying) requests too, so the edge absorbs logged-in read load as well (the anonymous-only description is the pre-ADR-040 behavior). They are not unified by design: different keys, different lifetimes, different eviction.
  • TTL-bounded correctness over distributed-invalidation guarantees. A short default TTL makes the cache eventually consistent cheaply, so the system stays correct-enough even where prefix invalidation is best-effort, rather than depending on a perfectly fan-out invalidation.

Trade-offs

  • Memory mode is per-replica. In the in-process store each replica caches independently; a scaled-out deployment that did not wire Redis would see cross-replica staleness bounded only by the TTL. The framework's answer is to register a distributed cache once scaled out (both apps do), which bounds cross-replica staleness rather than removing it: with Redis configured each replica still holds an L1 copy, and an eviction on one replica leaves the others' copies serving for up to Cache:LocalCacheDuration (MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:29-32, :305-316; see the next bullet).
  • Cross-replica prefix invalidation needs the multiplexer, and the composed service host registers it once through one framework wrapper. HybridCacheService.RemoveByPrefixAsync (MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:333-337) writes its generation token through the IConnectionMultiplexer the registration resolves (MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:193); without one the tokens are process-local, so the invalidation reaches the invalidating process only and is warned once (MMCA.Common.Infrastructure/Caching/CachePrefixGenerations.cs:224-231). Putting it there is no longer each host's business: builder.AddRedisCaching() (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Caching/RedisCachingExtensions.cs:69) registers the distributed cache (:76) and the client (:77) together, both with DisableHealthChecks = true, and no-ops when the named connection string is blank. The wrapper exists because the raw Aspire integrations register an untagged StackExchange.Redis health check, which readiness therefore includes, and against Azure Managed Redis that check issues CLUSTER INFO, a command the client refuses outside admin mode: every probe threw and every replica reported not ready (ADR-025 owns that decision and the PING-only replacement check). The wrapper is called once, unconditionally, by the composed service host (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:89), since it no-ops on its own (RedisCachingExtensions.cs:71-74), so all seven ADC and Store services reach it through AddMmcaServiceHost (Tier 1 above lists the seven call sites). Only AddCommonHybridCache(), which has no guard of its own, is reached conditionally, through the guarded AddCommonHybridCacheWhenRedisConfigured(...) helper the same host calls (ServiceHostBuilderExtensions.cs:95). No service Program.cs in either repo's Source/ tree calls AddRedisCaching, and the wrapper holds the only AddRedisDistributedCache / AddRedisClient calls (RedisCachingExtensions.cs:76-77). So whenever Redis is configured, a prefix invalidation is one Redis write that every replica observes, whatever the size of the keyspace. It does not reach every copy at once, though: another replica's L1 copy of a single removed key keeps serving until its local expiration lapses (MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:305-316), and another replica stops serving an invalidated prefix once its remembered token expires, within Cache:LocalCacheDuration (30 seconds by default) plus one refresh round trip (MMCA.Common.Infrastructure/Caching/CachePrefixGenerations.cs:37-42); a read that must see a removal everywhere goes through GetFromSharedStoreAsync (HybridCacheService.cs:266). So the 30-second bound is the cross-replica backstop in hybrid mode as well as the whole answer in memory mode, where prefix removal self-heals within seconds instead.
  • Distributed mode pays serialization and a network hop. Values cross the wire as JSON; large or hot objects cost more than the in-process path.
  • Counter increments are not atomic, and that is the accepted position. ICacheService.IncrementAsync is a default interface member implemented as a read-modify-write (MMCA.Common.Application/Interfaces/ICacheService.cs:133), which MemoryCacheService inherits. With Redis configured the override that runs is HybridCacheService.IncrementAsync (MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:362), also a read-modify-write rather than Redis INCR, with both legs on L2 only (remarks at :339-361). The reason is a storage format mismatch, documented on the interface (MMCA.Common.Application/Interfaces/ICacheService.cs:126-132): INCR writes a Redis string, while StackExchangeRedisCache (the L2 under HybridCache) stores every entry as a Redis hash (absexp / sldexp / data, read back with HMGET). An INCR-written counter therefore makes the next read of that key fail with WRONGTYPE, which surfaces as a 500 on whatever endpoint owns the counter (registration and login, in the ADR-029 case). A counter has to live in the same storage format as the reads that consult it, so readability wins over atomicity here: the ADR-029 brute-force and rate-limit counters can undercount under genuinely concurrent increments, and an occasional lost increment is the accepted cost of a counter that is always readable. The interface says the same thing: its <summary> states the member is not atomic in any shipped implementation (MMCA.Common.Application/Interfaces/ICacheService.cs:115-121), and its <remarks> records that no shipped implementation overrides it with Redis INCR, for the storage-format reason above (:126-132, the sentence at :129-131).
  • Output caching is opt-in per service. The composed host registers AddOutputCache with the NoCache base for every service (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:110-114), so a read-heavy service that supplies no ConfigureOutputCache callback with a real named policy (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/MmcaServiceHostOptions.cs:60) gets no edge caching (the NoCache base is the safe default), the same audit-the-inventory caveat as other opt-in capabilities (ADR-019/020/021). Adopting a policy is only half the decision: the store behind it is per-replica memory unless the service also sets UseRedisOutputCaching (MmcaServiceHostOptions.cs:55), which makes the host call the shared Redis output-cache wrapper (ServiceHostBuilderExtensions.cs:90-93, Tier 2 above), and that is what a multi-replica adopter needs for tag eviction to reach every replica (ADR-040).
  • No client tier, by decision. The framework offers no client-side read cache (removed 2026-11-17), so every UI read reaches Tier 2 or the handler. The cost is a round trip per read on a hot page; the gain is that a user never sees a value older than the server's own caches allow, and an application that measures a hot reference read memoizes that one read where its invalidation is obvious.

Revision (2026-09-07)

Four changes from the 2026-09-07 security review. The tiers themselves are unchanged.

  1. Tier-1 keys are caller-scoped where the result is caller-scoped (SEC-Common-19 / SEC-Common-37). CachingQueryDecorator composes TenantCacheKey.Scope(tenantContext, UserCacheKey.Scope(cacheable, cacheable.CacheKey)) (MMCA.Common/Source/Core/MMCA.Common.Application/UseCases/Decorators/CachingQueryDecorator.cs:59). UserCacheKey (MMCA.Common/Source/Core/MMCA.Common.Application/UseCases/Decorators/UserCacheKey.cs:26) appends the target user when the query implements IUserScopedRequest (MMCA.Common/Source/Core/MMCA.Common.Application/Users/IUserScopedRequest.cs:8); the ISharedQueryCache marker (MMCA.Common/Source/Core/MMCA.Common.Application/UseCases/Markers/ISharedQueryCache.cs:21) opts a genuinely public result back out. Because the caller segment is a suffix, prefix invalidation still clears every caller's copy in one sweep.
  2. The public output-cache key varies by resolved tenant (SEC-Common-46). PublicEndpointOutputCachePolicy stamps ITenantContext.TenantId into CacheVaryByRules under the t key (MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:50, :102-105), mirroring the t:{tenantId} prefix the CQRS decorators already used. An unresolved tenant (a single-tenant host, a background call) adds nothing to the key, so nothing changes for the deployments that have no tenant.
  3. Roles are read one way. The policy's bypass check goes through ClaimsPrincipalExtensions.HasRole (MMCA.Common/Source/Core/MMCA.Common.Shared/Auth/ClaimsPrincipalExtensions.cs:75, over GetRoleValues at :59, which reads ClaimTypes.Role, role and roles case-insensitively), applied at PublicEndpointOutputCachePolicy.cs:142. A narrower read here than the permission handler's meant a privileged caller under an unmapped claim type could have an elevated response stored under the shared public key.
  4. The cache key prefix is namespaced per application. Cache:KeyPrefix left unset now defaults to the resolved application namespace (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Caching/CacheKeyPrefix.cs:83, rationale at :68), and the distributed-lock keyspace follows it. Two applications sharing one Redis no longer collide, at the cost of a cold cache on the deploy that adopts it.

ADR-014 (the Caching decorators and IQueryCacheable / ICacheInvalidating markers that consume this substrate), ADR-019 (output caching as the anonymous-traffic lever, and LoginProtectionService is another ICacheService consumer), ADR-006 / ADR-008 (the same monolith-to-services swap boundary this substrate follows), ADR-025 (why both tiers reach Redis through MMCA.Common.Aspire's AddRedisCaching / AddRedisOutputCaching wrappers rather than Aspire's integrations directly, and the PING-only health check that replaced the untagged one), ADR-040 (amends this ADR's Tier 2: the adopters' public-read policies cache authenticated, bearer-carrying requests too, not only anonymous traffic, and its CacheVaryByRules.QueryKeys = "*" rule is the key shape the optional client tier mirrors), ADR-077 (amends this ADR's Tier 1: the opt-in HybridCacheService substrate, the disjoint hc: keyspace that generalizes the WRONGTYPE lesson recorded in the counter trade-off above, and the L1 bypass that keeps IncrementAsync semantics unchanged), ADR-090 (the upcaster registration and the RegisterUpcastedIntegrationEventConsumer<TEvent> sibling that a future reshape of this ADR's OutputCacheEvictionRequested contract would go through).

Revision (2026-07-24)

Three substrate corrections from a code review.

  1. An optional key namespace (Cache:KeyPrefix). Services sharing one cache instance also share one keyspace, and nothing stopped two of them choosing the same key for different data. The prefix is applied inside DistributedCacheService rather than through RedisCacheOptions.InstanceName deliberately: InstanceName is prepended below this abstraction, where prefix invalidation cannot see it, so the SCAN in RemoveByPrefixAsync would look for product:* while the stored keys were svc:product:* and evict nothing, silently. Applying it here keeps get, set, remove, the SCAN pattern and the Redis counter working from one key shape. MemoryCacheService ignores it: its keyspace is private to the process by construction.
  2. Prefix invalidation survives an overwrite. MemoryCacheService tracks live keys in a side dictionary because IMemoryCache cannot enumerate, and its post-eviction callback removed the key for every eviction reason. IMemoryCache queues those callbacks to the thread pool, so overwriting a live key fired the old entry's callback asynchronously and it could land after the replacement was tracked, deleting the tracking record for an entry that was still cached. That entry was then live but invisible to RemoveByPrefixAsync and clearable only by its TTL. The callback now skips EvictionReason.Replaced; genuine evictions still clean up.
  3. ICacheService.IncrementAsync. A default interface member (so no implementer breaks), added as the single entry point for the ADR-029 counters. It is a read-modify-write, and DistributedCacheService deliberately keeps that shape rather than reaching for Redis INCR: see the counter trade-off above for the storage-format reason and why the non-atomicity is accepted.

The query-cache stampede lock also moved to a fixed-width KeyedSemaphoreStripe. The previous per-key dictionary was documented as bounded by the set of distinct cache keys, which holds only for parameterless keys; any CacheKey embedding a user id or filter value grew it without bound.

Revision (2026-07-25)

An audit against the code. No behavior changed; the ADR text did.

  1. The IncrementAsync entry above was wrong. It described a Redis INCR override. There is no such override, and none is intended: both the default interface member and DistributedCacheService's implementation are read-modify-write, because a counter written by INCR (a Redis string) cannot be read back by the hash-shaped StackExchangeRedisCache path that consults it. The resulting non-atomicity is recorded in Trade-offs as the accepted position, not as an open defect.
  2. Tier 2 now records the output-cache store, not just the policies. ADC Conference and Store Catalog back the output cache with Redis when Redis is configured, so tag eviction crosses replicas; the in-memory store remains the single-replica case. This tracks ADR-040's 2026-07-25 amendment.
  3. Refreshed line anchors for AddCaching and for the two adopters' paired Redis registrations. That refresh did not hold: four of the per-service citations it covered no longer matched the code when the ADR was next swept, so read this item as the state on 2026-07-25 only. The 2026-07-28 entry below re-anchored them.

Revision (2026-07-28)

Line anchors only, re-verified against the current source. No decision, no behavior, and no substantive prose changed.

  1. Tier 2. Store Catalog's AddStackExchangeRedisOutputCache(...) is at Program.cs:90; the previously cited :88 had become a line inside the comment above the call. ADC Conference's Program.cs:129 was re-checked and still holds.
  2. Trade-offs, the seven paired Redis registrations. Three moved: ADC Identity to Program.cs:108,113 (from :109,114), Store Catalog to Program.cs:75,80 (from :73,78), and Store Identity to Program.cs:79,84 (from :77,82). The other four were re-checked and are unchanged: ADC Conference :113,118, ADC Notification :99,104, ADC Engagement :88,93, Store Sales :76,81. AddCaching at MMCA.Common.Infrastructure/DependencyInjection.cs:149 is also unchanged, as are the Tier 2 policy anchors in MMCA.Common.API and the counter anchors in ICacheService / DistributedCacheService.
  3. The 2026-07-25 anchor claim is annotated rather than removed, so the history stays readable without asserting an accuracy it no longer had.

Revision (2026-08-01)

Line anchors only, re-verified against the current source. No decision, no behavior, and no substantive prose changed.

  1. AddCaching. Now at MMCA.Common.Infrastructure/DependencyInjection.cs:150 (from :149); the previous line is the <returns> doc comment above the declaration, not the declaration itself.
  2. Tier 2. Store Catalog's AddStackExchangeRedisOutputCache(...) moved again, to Program.cs:96 (from the 2026-07-28 anchor of :90, itself a correction of an earlier :88). ADC Conference's moved to Program.cs:135 (from :129).
  3. Trade-offs, the seven paired Redis registrations. All seven shifted by the same six lines: ADC Conference to Program.cs:119,124 (from :113,118), Notification to Program.cs:105,110 (from :99,104), Engagement to Program.cs:94,99 (from :88,93), Identity to Program.cs:114,119 (from :108,113); Store Catalog to Program.cs:81,86 (from :75,80), Sales to Program.cs:82,87 (from :76,81), Identity to Program.cs:85,90 (from :79,84).
  4. Counter anchors. DistributedCacheService's IncrementAsync override is now at DistributedCacheService.cs:175-181 (from :122-128), and the storage-format-mismatch <remarks> documenting it is now at DistributedCacheService.cs:156-174 (from :104-121). The old line range for both now falls inside the unrelated RemoveByPrefixAsync / ScanAndDeleteAsync SCAN logic.
  5. The 2026-07-28 anchor claim is annotated rather than removed, consistent with how that revision itself treated the 2026-07-25 entry: the anchors it recorded were correct on 2026-07-28 and have since drifted again.

Revision (2026-08-07)

Line anchors only, re-verified against the current source. No decision, no behavior, and no substantive prose changed.

  1. AddCaching. Now at MMCA.Common.Infrastructure/DependencyInjection.cs:157 (from :150); line 150 is now the closing brace of the preceding method. The registration behavior it describes (DistributedCacheService when a real, non-MemoryDistributedCache IDistributedCache is present, MemoryCacheService otherwise) is unchanged.
  2. The 30-second default TTL now cites its source. The figure was asserted without an anchor; it is verified and the anchor added (MMCA.Common.Infrastructure/Caching/CacheOptions.cs:14-17, TimeSpan.FromSeconds(30)).
  3. Tier 2. ADC Conference's AddStackExchangeRedisOutputCache(...) moved to Program.cs:147 (from :135) and Store Catalog's to Program.cs:98 (from :96).
  4. Trade-offs, the seven paired Redis registrations. Six moved: ADC Conference to Program.cs:131,136 (from :119,124), Notification to Program.cs:106,111 (from :105,110), Engagement to Program.cs:96,101 (from :94,99), Identity to Program.cs:123,128 (from :114,119); Store Catalog to Program.cs:83,88 (from :81,86), Identity to Program.cs:87,92 (from :85,90). Store Sales was re-checked and is unchanged at :82,87. The Tier 2 policy anchors in MMCA.Common.API (WebApplicationExtensions.cs:104, OutputCacheOptionsExtensions.cs:20, PublicEndpointOutputCachePolicy.cs:35, :71-75, :109-113) and the counter anchors (ICacheService.cs:57, DistributedCacheService.cs:156-174 and :175-181) were re-checked and are unchanged.
  5. The 2026-08-01 anchor claim is annotated rather than removed, consistent with how the two preceding revisions treated their predecessors: the anchors it recorded were correct on 2026-08-01 and have since drifted again.

Every anchor in this entry was correct on 2026-08-07 and has since drifted, the CacheOptions citation in item 2 included: read the whole entry as the state on that date, and the 2026-08-14 entry below for the current anchors.

Revision (2026-08-13)

Tier 1 is amended by ADR-077, which is where the decision and its trade-offs are recorded. The three points that change the reading of this record:

  1. A third substrate, opted into rather than auto-selected. HybridCacheService (L1 in-process plus L2 distributed, Microsoft.Extensions.Caching.Hybrid) joins MemoryCacheService and DistributedCacheService. AddCaching()'s presence-of-a-real-IDistributedCache swap still decides between the original two; AddCommonHybridCache(...) replaces the result. A host that does not call it gets byte-identical behavior to this record as written.
  2. The counter trade-off above is generalized into a keyspace rule. The WRONGTYPE incident documented in Trade-offs (a Redis INCR string read back by the hash-shaped StackExchangeRedisCache path) is a class of bug, not one occurrence: two serialization formats must never share one keyspace. The hybrid substrate therefore writes under a disjoint {prefix}hc:{key} keyspace, so a cross-format read cannot happen at all, and prefix eviction scans that one keyspace: what this substrate writes is exactly what it evicts. The non-atomic read-modify-write IncrementAsync position is unchanged, and the hybrid implementation bypasses L1 on both legs precisely to keep it unchanged.
  3. Nothing in Tier 2 moves. The output-cache edge, its policies and its Redis-backed store are untouched by ADR-077.

Revision (2026-08-14)

One substrate correction plus a line-anchor re-verification. No decision and no behavior changed.

  1. The 30-second default now has a named home, CacheOptions.DefaultDuration. Tier 1 described the default TTL as a literal TimeSpan.FromSeconds(30) inside a DistributedCacheEntryOptions. CacheOptions has since gained a DefaultDuration property (CacheOptions.cs:17), a bare TimeSpan added for the ADR-077 HybridCacheService, whose entry options are HybridCacheEntryOptions rather than DistributedCacheEntryOptions and so could not have reused that entry-options value without hard-coding the figure a second time. The entry-options value then read AbsoluteExpirationRelativeToNow = DefaultDuration (CacheOptions.cs:22-25); it is gone since v1.331.0 (Revision 2026-12-03). The value is still 30 seconds and every claim built on it still holds; there is now one place to change it.
  2. The seven paired Redis registrations are confirmed exhaustive. Previous revisions re-anchored the seven named services one by one without ever asking whether an eighth had appeared. A sweep of both repos' Source/ trees for AddRedisDistributedCache / AddRedisClient returns exactly these fourteen call sites, so "all seven services" is a verified count, not an assumption. The Trade-offs entry now says so.
  3. AddCaching. Now at MMCA.Common.Infrastructure/DependencyInjection.cs:164 (from :157); line 157 is now the closing brace of the preceding method.
  4. Tier 2. app.UseOutputCache() moved to WebApplicationExtensions.cs:111 (from :104). ADC Conference's AddStackExchangeRedisOutputCache(...) moved to Program.cs:156 (from :147) and Store Catalog's to Program.cs:117 (from :98).
  5. Trade-offs, the seven paired Redis registrations. All seven moved: ADC Conference to Program.cs:140,145 (from :131,136), Notification to Program.cs:114,119 (from :106,111), Engagement to Program.cs:111,116 (from :96,101), Identity to Program.cs:131,136 (from :123,128); Store Catalog to Program.cs:94,99 (from :83,88), Sales to Program.cs:111,116 (from :82,87), Identity to Program.cs:100,105 (from :87,92).
  6. Counter anchors. DistributedCacheService's IncrementAsync is now at DistributedCacheService.cs:127-133 (from :175-181) and the storage-format-mismatch <remarks> documenting it at DistributedCacheService.cs:108-126 (from :156-174), a move of about 48 lines up. The read-modify-write behavior and the reason for it are unchanged. ICacheService.cs:57 and the Tier 2 policy anchors (OutputCacheOptionsExtensions.cs:20, PublicEndpointOutputCachePolicy.cs:35, :71-75, :109-113) were re-checked and are unchanged.
  7. The 2026-08-07 anchor claim is annotated rather than removed, consistent with how every preceding revision treated its predecessor: the anchors it recorded were correct on 2026-08-07 and have since drifted again.

Items 1, 3, 4 and 6 of this entry were correct on 2026-08-14 and have since drifted, and item 4's WebApplicationExtensions.cs home no longer exists at all: read the entry as the state on that date, and the 2026-08-23 entry below for the current anchors.

Revision (2026-08-18)

Every previous revision moved Tier 1. This one moves Tier 2, and it is the first change to the output-cache edge since ADR-040.

Tier 2 as decided here is per-process by construction: each host calls UseOutputCache, owns its own policies, and evicts by tag through its own IOutputCacheStore. In a database-per-service deployment (ADR-006/008) the thing that invalidates a cached read frequently happens somewhere else: a mutation in one service makes another service's cached public read wrong, and that service has no way to hear about it. The eviction call and the write that requires it were in different processes, so the only invalidation that crossed a boundary was the expiry clock.

An integration event carries the eviction

OutputCacheEvictionRequested (MMCA.Common/Source/Core/MMCA.Common.Domain/IntegrationEvents/OutputCacheEvictionRequested.cs:29) is a sealed record over BaseIntegrationEvent whose only own member is IReadOnlyList<string> Tags { get; init; } = [] (:37), inheriting SchemaVersion => 1 (.../DomainEvents/BaseIntegrationEvent.cs:32) and therefore ADR-010's versioning contract. It is the first concrete integration event the framework itself ships: a repository-wide search of Source/ finds no other, every prior hit being the interface, the abstract base or generic plumbing. Until now the framework provided the delivery machinery and consumers provided all the messages.

Tags defaulting to empty is a safety decision, not a formality. An empty list means evict nothing, so a message that arrives malformed, from an older producer, or with a property the consumer cannot bind, degrades to a no-op instead of to a cache-wide flush. The failure mode of the default is a stale response, which the TTL already bounds; the alternative default would have made a deserialization accident indistinguishable from an intentional purge.

Delivery reuses the whole existing path rather than adding a channel: the producing service raises the event, ADR-003's outbox persists and publishes it, ADR-066's broker carries it, and ADR-021's inbox dedups the redelivery. Nothing about eviction is transactional or exactly-once, and it does not need to be: evicting twice is free, and evicting late is what a TTL is for.

The consumer side is two registrations in two packages

RegisterOutputCacheEvictionConsumer(bool registerFaultConsumer = true) (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Messaging/Consumers/IntegrationEventConsumerExtensions.cs:108-110) is the MassTransit-side shorthand for RegisterIntegrationEventConsumer<OutputCacheEvictionRequested>(), so it inherits ADR-087's fault consumer by default. It now sits below a sibling in that same file, RegisterUpcastedIntegrationEventConsumer<TEvent> (:78-90), the ADR-090 registration a host adds while a retired contract still drains from a queue. The two are alternatives on one event, never both: registering a plain and an upcasting consumer for the same type puts two consumers on one queue. AddOutputCacheEvictionHandler() (MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/OutputCacheEvictionExtensions.cs:111) registers the handler itself, through TryAddEnumerable (:115-117). They are in different packages because the two halves are genuinely different concerns (broker registration is Infrastructure, output caching is API), and a host that calls only one gets silence: the consumer without the handler receives and discards, the handler without the consumer is never invoked.

OutputCacheEvictionHandler (.../MMCA.Common.API/Caching/OutputCacheEvictionHandler.cs:32) loops the tags, skips blank ones, and catches per tag so one failing tag cannot abandon the rest (:44-63), rethrowing only OperationCanceledException so a stopping host is not counted as a cache failure. Failures increment cache.eviction.failed, tagged cache_tag, on a new meter MMCA.Common.OutputCache (.../Caching/OutputCacheMetrics.cs:19, instrument at :29-37), subscribed by the Aspire defaults (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Extensions.cs:204).

One deliberate non-reuse: the handler does not route through the BestEffort.ExecuteAsync helper that shipped in the same release. BestEffort lives in the Application layer and counts on its own MMCA.Common.BestEffort meter, which the API package cannot reach without either a layer-crossing reference or a duplicated meter name; the handler therefore hand-rolls the same swallow-log-count shape against its own instrument. That is a small duplication chosen over a worse coupling, and it is the reason two "best effort" counters exist in one release.

What this revision costs

  • Cross-service eviction is asynchronous and unordered relative to the write. The stale window is at least an outbox poll plus broker delivery plus the consumer's own scheduling, so a reader can observe the old response after the writer's transaction has committed. Tier 2 was always eventually-consistent; this makes the eventual explicit and measurable rather than bounded by the TTL alone.
  • The tag vocabulary is a shared string contract nothing validates. The producer names a tag the consumer's policies must also name. A typo evicts nothing and counts nothing, because evicting an unknown tag succeeds: the failure counter sees only faults, never misses, so the most likely error is the one with no signal.
  • cache.eviction.failed has no alert and no runbook section. It joins the counters ADR-087 also left unwired (ADR-062), so a service quietly failing every eviction is visible only to someone already looking at the meter.
  • The two-call registration is an inventory item. Nothing fails a build, a test or a startup when a host wires one half, and both halves are opt-in per host on top of that.
  • The framework now owns a wire contract. OutputCacheEvictionRequested is a published shape that ADR-010's rules apply to, so a future field is an additive change with an upcaster or a new type, never a reshape, and that obligation now sits on the framework rather than only on consumers.
  • Tier 1 and Tier 2 remain separate invalidation models. A single mutation may need a Tier 1 prefix invalidation and a Tier 2 tag eviction, and nothing coordinates them; ADR-077 moved one, this revision moves the other, and they still do not meet.

Revision (2026-08-23)

One correction of substance plus a line-anchor re-verification. No decision and no behavior changed.

  1. The counter trade-off now names the contradiction a reader will hit. ICacheService's <remarks> on IncrementAsync says that backing stores which can do better with Redis INCR override it (MMCA.Common.Application/Interfaces/ICacheService.cs:54-57). Nothing does. The only store that could, DistributedCacheService, deliberately keeps the read-modify-write and documents why at its own implementation (DistributedCacheService.cs:107-133). The Revision (2026-07-25) already recorded that no INCR override exists or is intended, but this ADR never said that the interface comment still points the other way, so a reader starting from the interface reached the opposite conclusion. Trade-offs now says which of the two comments describes shipped behavior. The source comment is unchanged by this entry; only the ADR is.
  2. Tier 2's UseOutputCache call has a new home, and a different shape of home. app.UseOutputCache() is no longer an inline call in MMCA.Common.API/Startup/WebApplicationExtensions.cs (it is not in that file at all). The shared middleware pipeline is now assembled from named steps: the output-cache step is at MMCA.Common.API/Startup/MiddlewarePipelineBuilder.cs:138, named by MiddlewarePipelineStepNames.OutputCache (MMCA.Common.API/Startup/MiddlewarePipelineStepNames.cs:64). The decision is untouched, the pipeline still always enables output caching and still ships no policies, but the citation now points at a builder rather than at a sequence of calls.
  3. The eviction event's method surface gained an ADR-090 sibling. RegisterOutputCacheEvictionConsumer moved to IntegrationEventConsumerExtensions.cs:108-110 (from :68-70) because RegisterUpcastedIntegrationEventConsumer<TEvent> (:78-90) was added above it, the registration ADR-090 defines for draining a retired contract. The 2026-08-18 revision predates it and did not mention it; the consumer paragraph now does, including that the two are alternatives on one event rather than a pair. ADR-090 is added to Related.
  4. Remaining anchors. AddCaching is now at MMCA.Common.Infrastructure/DependencyInjection.cs:177 (from :164). OutputCacheEvictionRequested's declaration is at :27 and Tags at :35 (from :23 and :31), both pushed down four lines by a Frozen-contract-candidate paragraph added to the doc comment. BaseIntegrationEvent.SchemaVersion is at :32 (from :22), likewise behind added doc text. ICacheService's IncrementAsync declaration is at :59 (from :57; :57 is now the last line of the <remarks> discussed in item 1). Re-checked and unchanged: CacheOptions.cs:17 and :22-25, both adopters' AddStackExchangeRedisOutputCache calls and all seven paired Redis registrations, DistributedCacheService.cs:108-126 and :127-133, the Tier 2 policy anchors (OutputCacheOptionsExtensions.cs:20, PublicEndpointOutputCachePolicy.cs:35, :71-75, :109-113), OutputCacheEvictionExtensions.cs:32 and :36-38, OutputCacheEvictionHandler.cs:32 and :44-63, OutputCacheMetrics.cs:19 and :29-37, and MMCA.Common.Aspire/Extensions.cs:169.
  5. The 2026-08-14 anchor claim is annotated rather than removed, consistent with how every preceding revision treated its predecessor.

Item 4's "re-checked and unchanged" list did not hold: CacheOptions, both adopters' AddStackExchangeRedisOutputCache calls, all seven paired Redis registrations and the DistributedCacheService counter anchors have all moved since. Read items 1 and 4 as the state on 2026-08-23, and the 2026-08-31 entry below for the current anchors. Item 2's MiddlewarePipelineStepNames.cs:64 was an off-by-one from the start rather than drift: :64 is the XML doc comment and the const it names is at :65, corrected in the Decision by the 2026-09-01 entry below. The two file paths this entry records have also moved since: the pipeline builder and its step names are now under MMCA.Common.API/Startup/Pipeline/, and IntegrationEventConsumerExtensions.cs is now under MMCA.Common.Infrastructure/Messaging/Consumers/, both corrected in the live sections by the 2026-09-03 entry.

Revision (2026-08-31)

Line anchors only, re-verified against the current source. No decision, no behavior, and no substantive prose changed.

  1. AddCaching. Now at MMCA.Common.Infrastructure/DependencyInjection.cs:215 (from :177); line 177 is now inside AddInfrastructure, at its IOutboxSignal registration. The presence-of-a-real-IDistributedCache swap it describes is unchanged.
  2. CacheOptions. DefaultDuration is at CacheOptions.cs:23 (from :17, now a line of the doc comment above it) and the entry-options value's AbsoluteExpirationRelativeToNow = DefaultDuration at :28-31 (from :22-25). The figure is still 30 seconds and still has exactly one home.
  3. Tier 2. ADC Conference's AddStackExchangeRedisOutputCache(...) is at Program.cs:140 (from :156) and Store Catalog's at Program.cs:96 (from :117).
  4. Trade-offs, the seven paired Redis registrations. All seven moved up: ADC Conference to Program.cs:124,129 (from :140,145), Notification to Program.cs:98,103 (from :114,119), Engagement to Program.cs:95,100 (from :111,116), Identity to Program.cs:116,121 (from :131,136); Store Catalog to Program.cs:73,78 (from :94,99), Sales to Program.cs:89,94 (from :111,116), Identity to Program.cs:78,83 (from :100,105). The 2026-08-14 exhaustiveness check still holds: a sweep of both repos' Source/ trees for AddRedisDistributedCache / AddRedisClient returns these same fourteen call sites and no eighth service.
  5. Counter anchors. DistributedCacheService's IncrementAsync override is now at DistributedCacheService.cs:146-152 (from :127-133) and the storage-format-mismatch <remarks> documenting it at :127-145 (from :108-126); the old range now falls inside the unrelated RemoveByPrefixAsync (its no-multiplexer warning and Redis SCAN delete). The read-modify-write behavior and the reason for it are unchanged, and ICacheService.cs:54-57 / :59 were re-checked and still hold, so item 1 of the 2026-08-23 entry stands as written.
  6. The eviction event. OutputCacheEvictionRequested's declaration is at :29 and Tags at :37 (from :27 and :35), both pushed down two lines by the [EventName("Common.OutputCacheEvictionRequested.v1")] attribute now sitting on the type (:28) and the using it needs (:1). Re-checked and unchanged: IntegrationEventConsumerExtensions.cs:108-110 and :78-90, and the Tier 2 policy anchors (OutputCacheOptionsExtensions.cs:20, PublicEndpointOutputCachePolicy.cs:35, :71-75, :109-113).
  7. The 2026-08-23 anchor claim is annotated rather than removed, consistent with how every preceding revision treated its predecessor.

Every anchor in this entry has since drifted, and items 3 and 4 describe calls the applications no longer make at all: read the whole entry as the state on 2026-08-31, and the 2026-09-03 entry below for the current wiring and anchors.

Revision (2026-09-01)

One amendment of substance (an optional third tier is recorded) plus line anchors for the files the 2026-08-31 entry did not re-read. No behavior changed, and neither server tier changed.

  1. The eviction registration. AddOutputCacheEvictionHandler() is now at MMCA.Common.API/Caching/OutputCacheEvictionExtensions.cs:111 (from :32) and its TryAddEnumerable call at :115-117 (from :36-38). The class itself is still the head of the file (:27); what moved the members is a second extension(T) block added above the extension(IServiceCollection services) one (:36 and :95 respectively), holding the multi-tag eviction helpers EvictTagsAsync (:49) and its best-effort sibling TryEvictTagsAsync (:78) that a mutating controller calls after a write, plus the EvictOperationPrefix const they name their operations from (:34). Two extension(T) blocks in one static class is also why the file now carries a CA1708 suppression (:23-26). The registration behavior the citation describes, one handler however many callers register it, is unchanged.
  2. Re-checked and unchanged. OutputCacheEvictionHandler.cs:32 (the class) and :44-63 (the per-tag loop with its swallow-log-count catch), OutputCacheMetrics.cs:19 (the meter name) and :29-37 (the cache.eviction.failed instrument plus its recorder), and MMCA.Common.Aspire/Extensions.cs:169 (the meter subscription, which is the SIXTH of the seven chained AddMeter calls, not the fifth: they begin at MMCA.Common.Outbox on :164 and run Outbox, Cqrs, Idempotency, Scheduler, Broker, OutputCache, BestEffort). The 2026-08-31 entry's own anchors were not re-read this pass and stand as written there.
  3. The output-cache step name was cited one line high, and always had been. MiddlewarePipelineStepNames.OutputCache is declared at MMCA.Common.API/Startup/MiddlewarePipelineStepNames.cs:65; :64, the anchor the Decision and the Revision (2026-08-23) carried, is the XML doc comment above it. The Decision's citation is corrected here and the 2026-08-23 entry is annotated in place rather than rewritten. MiddlewarePipelineBuilder.cs:138, the app.UseOutputCache() step itself, was re-read and holds.
  4. An optional third tier is recorded: IUiReadCache, the client-side read-through cache. No code moves with this entry; this is shipped code the ADR had never described. A new Decision subsection and a new Trade-offs bullet record it: per-circuit read-through over the API client, keyed by the relative URL so the key shape matches Tier 2's QueryKeys = "*" (PublicEndpointOutputCachePolicy.cs:81), a default TTL plus longest-prefix per-route overrides (UiReadCacheOptions.cs:32 and :41), successes-only storage (EntityServiceBase.cs:262-264), prefix invalidation on a successful write (:285) and a clear on sign-out (AuthUIService.cs:127). It is DI-registered by AddUIShared (MMCA.Common.UI/DependencyInjection.cs:57) and still opt-in per service, through an optional constructor parameter that defaults to null (EntityServiceBase.cs:47), and no consumer app passes it: ADC, Store and Helpdesk contain no reference to the type at all. It is recorded as a capability and an inventory item, not as something to adopt in a sweep. The title stays "Two-Tier Caching" on purpose: two tiers are what this ADR decides, and the client one is optional.
  5. The 2026-08-31 anchor claim is annotated rather than removed, consistent with how every preceding revision treated its predecessor.

Items 2 and 4 of this entry have since drifted: the meter subscription is at MMCA.Common.Aspire/Extensions.cs:204, AddUIShared's registration at MMCA.Common.UI/DependencyInjection.cs:61, the sign-out clear at AuthUIService.cs:130, and EntityServiceBase.cs now lives under MMCA.Common.UI/Services/Api/. Read the entry as the state on 2026-09-01, and the 2026-09-03 entry below for the current anchors.

Revision (2026-09-03)

Two substrate corrections plus a line-anchor and file-path re-verification. No decision changed; what changed is where the wiring lives and which substrate the applications actually run.

  1. Redis is wired through framework wrappers now, not by each host. Neither repo calls Aspire's AddRedisDistributedCache / AddRedisClient / AddStackExchangeRedisOutputCache any more. All three calls live once, in MMCA.Common.Aspire.Caching.RedisCachingExtensions (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Caching/RedisCachingExtensions.cs:29), behind AddRedisCaching() (:57, registering the cache at :64 and the client at :65) and AddRedisOutputCaching() (:91, the single AddStackExchangeRedisOutputCache call at :99). Both wrappers disable the Aspire integrations' health checks and no-op when the connection string is absent, which is why a service can call them unconditionally (the four ADC services did from this entry on, and the three Store services followed, see the Revision (2026-09-25)). The reason is a production incident this ADR had no record of: the raw integrations register an untagged StackExchange.Redis check that readiness includes, it issues CLUSTER INFO, and Azure Managed Redis is detected as a cluster by StackExchange.Redis 3.x, which refuses the command without admin mode. Every probe threw and every replica reported not ready. ADR-025 owns that decision; it is added to Related and the Trade-offs bullet now names it.
  2. HybridCacheService is what production runs. ADR-077's substrate was recorded here as opt-in, which is still true of the mechanism, but the Tier 1 narrative read as though the memory-or-distributed auto-swap is what runs everywhere. It is not: all seven ADC and Store services call AddCommonHybridCache() (MMCA.Common.Infrastructure/DependencyInjection.cs:340) inside their redis-connection-string conditional, so DistributedCacheService is the live ICacheService in no deployed service. The auto-swap is the no-Redis path: local runs, tests, and any host that wires no Redis. Tier 1 now says so and carries the seven anchors.
  3. Tier 2 gains a cache-bypassing-roles policy overload. AddPublicEndpointPolicy(name, expiration, bypassRoles, tags) (MMCA.Common.API/Caching/OutputCacheOptionsExtensions.cs:34) sits beside the three-argument overload the ADR already cited (:20), and a caller in a named role skips the cache entirely, no lookup and no storage. ADC Conference uses it for every policy but one (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:216-244 on that date); Store Catalog's four policies (Program.cs:150-155) use the plain overload. That materially qualifies "public-read policies cache authenticated requests too", so a new Decision bullet records it.
  4. Three cited files moved into sub-folders. MiddlewarePipelineBuilder.cs and MiddlewarePipelineStepNames.cs are under MMCA.Common.API/Startup/Pipeline/ (both line anchors, :138 and :65, still hold). EntityServiceBase.cs is under MMCA.Common.UI/Services/Api/ (all its line anchors still hold). IntegrationEventConsumerExtensions.cs is under MMCA.Common.Infrastructure/Messaging/Consumers/ (:108-110 and :78-90 still hold). Only the paths changed; the live sections carry the new ones.
  5. Line anchors. AddCaching is at MMCA.Common.Infrastructure/DependencyInjection.cs:229 (from :215, now a comment line inside AddInfrastructure), called from AddInfrastructure at :131. DistributedCacheService's IncrementAsync override is at :145-151 (from :146-152) and the storage-format-mismatch <remarks> at :126-144 (from :127-145); the behavior and the reason are unchanged. IUiReadCache's TryAddScoped is at MMCA.Common.UI/DependencyInjection.cs:61 (from :57, now blank; :56 is the TimeProvider.System registration it depends on). AuthUIService's two Clear() calls are at :130 and :159 (from :127 and :156). The MMCA.Common.OutputCache meter subscription is at MMCA.Common.Aspire/Extensions.cs:204 (from :169); the chain now runs :199-205 and OutputCache is still the sixth of seven. Re-checked and unchanged: CacheOptions.cs:23 and :28-31, ICacheService.cs:54-57 and :59, the Tier 2 policy anchors (PublicEndpointOutputCachePolicy.cs:35, :71-75, :81, :109-113), the whole IUiReadCache / UiReadCache / UiReadCacheOptions set, and EntityServiceBase's :47, :58, :229, :241, :248, :262-264, :281 and :285.
  6. The client tier is still adopted by no app. A search of all four repositories finds IUiReadCache only in MMCA.Common's own source and tests, so the 2026-09-01 entry's inventory claim stands.
  7. The 2026-08-31 and 2026-09-01 anchor claims are annotated rather than removed, consistent with how every preceding revision treated its predecessor.

Items 1, 2, 3 and 5 of this entry have since drifted: read their anchors as the state on 2026-09-03, and the 2026-09-25 entry below for the current wiring and anchors.

Revision (2026-09-25)

One wiring convergence, one count correction, and a line-anchor re-verification of the service call sites and the substrate registrations. No decision changed, and the ADC-only bypass list stays the sanctioned asymmetry it was.

  1. Store calls both Redis wrappers unconditionally, as ADC does. AddRedisCaching() and AddRedisOutputCaching() already no-op on a blank connection string (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Caching/RedisCachingExtensions.cs:59 and :94), so an outer connection-string branch around them in a host did nothing. The three Store services now call them top-level (Catalog MMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:88 and :98, Sales .../MMCA.Store.Sales.Service/Program.cs:103, Identity .../MMCA.Store.Identity.Service/Program.cs:92), and both repositories wire Redis one way. Only AddCommonHybridCache(), which has no guard of its own, stays behind the conditional in all seven services. Tier 1, Tier 2 and the multiplexer trade-off now say so.
  2. ADC Conference registers twelve public-read policies, and eleven take the bypass list. BookmarkCountsCache passes adminBypassRoles (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:297) beside the ten five-minute policies (:268-282); NowNextCache (:285) remains the one with no bypass list. The Decision bullet now gives the count as eleven of twelve.
  3. Line anchors. AddCaching is declared in the partial file MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:26 and called from AddInfrastructure at DependencyInjection.cs:134; AddCommonHybridCache is at DependencyInjection.Caching.cs:137. The seven AddCommonHybridCache() calls are at ADC Conference :203, Notification :119, Engagement :113, Identity :135, Store Catalog :109, Sales :114 and Identity :103. The seven AddRedisCaching() calls are at ADC Conference :183, Notification :109, Engagement :103, Identity :125, Store Catalog :88, Sales :103 and Identity :92, and the two AddRedisOutputCaching() calls at ADC Conference :193 and Store Catalog :98. Store Catalog's four policies are at Program.cs:154, :155, :161 and :164, and ADC Conference's adminBypassRoles array at :267. Re-checked and unchanged: RedisCachingExtensions.cs:29, :57, :64, :65, :91, :99 and OutputCacheOptionsExtensions.cs:20 and :34. The exhaustive sweep still holds: both repos' Source/ trees carry exactly these nine wrapper calls and no direct AddRedisDistributedCache / AddRedisClient / AddStackExchangeRedisOutputCache call.

Revision (2026-10-01)

One wiring correction, one recorded client-tier detail, and a line-anchor re-verification. No decision and no rationale changed.

  1. The hybrid opt-in is a framework helper now, not a host conditional. All seven ADC and Store services call AddCommonHybridCacheWhenRedisConfigured(builder.Configuration) (MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:200), which calls AddCommonHybridCache() (:139) only when the redis connection string is non-empty (:206-208). The outcome the 2026-09-25 entry recorded is unchanged (HybridCacheService wherever Redis is configured, the memory-or-distributed swap elsewhere); only where the guard lives moved. Call sites: ADC Conference Program.cs:202, Notification :118, Engagement :112, Identity :133; Store Catalog :107, Sales :112, Identity :101. Status, Tier 1 and the multiplexer trade-off now say so.
  2. The client tier's store is generation-checked. IUiReadCache gained a Generation member (MMCA.Common.UI/Services/Caching/IUiReadCache.cs:40) and a Set overload taking it (:70). GetCachedAsync captures the generation before the GET (EntityServiceBase.cs:261) and stores through that overload (:268), and UiReadCache drops the value when an InvalidatePrefix or Clear moved the generation meanwhile (UiReadCache.cs:119-122), so a write that lands during an in-flight read is not undone by the late store. The client tier is still adopted by no app: ADC, Helpdesk and Store origin/main carry no reference to IUiReadCache under Source/.
  3. Line anchors. MiddlewarePipelineBuilder.cs:132-133 (from :138); PublicEndpointOutputCachePolicy.cs:44 (from :35), CacheRequestAsync at :81-87 (from :71-75), QueryKeys = "*" at :96 (from :81), the helpers at :134 and :141 (from :109-113); the four Store Catalog policies at Program.cs:151, :152, :158, :161; ADC Conference's adminBypassRoles at :265, its bypass policies at :266-280 and :295, NowNextCache at :283, and AddRedisOutputCaching() at :194; ADC AddRedisCaching() at Conference :184, Notification :110, Engagement :104; ICacheService.IncrementAsync at :105 with the INCR remark at :103; DistributedCacheService's override at :153 and its <remarks> at :134-152; IUiReadCache members at :50, :59, :78, :85; MMCA.Common.UI/DependencyInjection.cs:63; UiReadCache.cs:163-178 with the comparison at :170; EntityServiceBase.cs:266-269, :285 and :289; AuthUIService.cs:352 (sign-out) and :162 (unrefreshable session). The MMCA.Common.OutputCache meter subscription cited in the Revision (2026-08-18) is now in the partial file MMCA.Common.Aspire/Extensions.Telemetry.cs:312, the sixth of nine chained AddMeter calls (:307-315). Re-checked and unchanged: DependencyInjection.Caching.cs:26, DependencyInjection.cs:134, CacheOptions.cs:23, MiddlewarePipelineStepNames.cs:65, OutputCacheOptionsExtensions.cs:20 and :34, RedisCachingExtensions.cs:57, :59, :64, :65, :91, :94, :99, ADC Identity :125 and the three Store AddRedisCaching() calls (:88, :103, :92) and Store Catalog's AddRedisOutputCaching() at :98.

Revision (2026-10-06)

Three content corrections plus a line-anchor re-verification. No decision changed.

  1. The client tier invalidates after any write that may have landed. InvalidateOnSuccess no longer exists; InvalidateAfterWrite (MMCA.Common.UI/Services/Api/EntityServiceBase.cs:300) drops the endpoint prefix on success and on every failure except validation, unprocessable-entity, unauthorized, forbidden and too-many-requests (:302, :309-314), so a 412, 404, 409, 5xx or transport failure invalidates too. The Decision bullet now says so.
  2. The default TTL is host-configurable. CacheSettings.DefaultDuration (MMCA.Common.Infrastructure/Caching/CacheSettings.cs:32, key Cache:DefaultDuration) defaults to CacheOptions.DefaultDuration, is bound by AddCaching(configuration) (DependencyInjection.Caching.cs:43-46) and is applied by the cache services (DistributedCacheService.cs:72). The 30-second figure still has one home; Tier 1 now names the override.
  3. ADC Conference's count is scoped to its public-read policies. Eleven of its twelve AddPublicEndpointPolicy registrations take the bypass list; a thirteenth named policy, ConferenceCache (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:236), is a plain built-in AddPolicy because a permission-gated controller also references it. Tier 2 now says so.
  4. Line anchors re-verified against current source. AddCaching is called at DependencyInjection.cs:140. The seven hybrid opt-ins are at ADC Conference :203, Notification :119, Engagement :116, Identity :138, Store Catalog :108, Sales :113, Identity :102; the seven AddRedisCaching() calls at ADC Conference :185, Notification :111, Engagement :108, Identity :130, Store Catalog :89, Sales :104, Identity :93; the two AddRedisOutputCaching() calls at ADC Conference :195 and Store Catalog :99. Store Catalog's four policies are at :152, :153, :159, :162; ADC Conference's adminBypassRoles at :266, its bypass policies at :267-268, :274-281 and :298, NowNextCache at :284. MMCA.Common.UI/DependencyInjection.cs:76; EntityServiceBase.cs key rule :239-241, GetCachedAsync :253, bypass path :260-263, generation :273, store :278-281; AuthUIService.cs:374 (sign-out) and :171 (unrefreshable session). Two anchors recorded only in the Revision (2026-08-18) have moved: RegisterOutputCacheEvictionConsumer is at MMCA.Common.Infrastructure/Messaging/Consumers/IntegrationEventConsumerExtensions.cs:158-160 and RegisterUpcastedIntegrationEventConsumer<TEvent> at :123-140 (now also taking an optional endpoint-configuration callback), and the MMCA.Common.OutputCache meter subscription is at MMCA.Common.Aspire/Extensions.Telemetry.cs:312. Re-checked and unchanged: DependencyInjection.Caching.cs:26, :139, :200, :206-208, CacheOptions.cs:23 and :28-31, RedisCachingExtensions.cs:57, :59, :64, :65, :91, :94, :99, and EntityServiceBase.cs:47 and :58.

Revision (2026-10-07)

Re-verified against current source. The two tiers, the substrate selection, the seven-service Redis and hybrid wiring, ADC Conference's eleven-of-twelve bypass count and the client tier are unchanged. One behavior description moved, the anchors in three files shifted, and new HybridCacheService citations were added.

  1. Eviction in hybrid mode does not reach other replicas' L1. The Trade-offs said that whenever Redis is configured cached entries are evicted on write and the 30-second TTL is the backstop only for memory mode. With Redis configured the live substrate is HybridCacheService, and its RemoveAsync and RemoveByPrefixAsync clear L2 and this process's L1 only: other replicas' L1 copies keep serving the removed value for up to Cache:LocalCacheDuration (30 seconds by default, MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:66; the L1 lifetime is the shorter of the entry TTL and that ceiling, :330-335; remarks at :192-195 and :210-212, and the class remarks at :30-32). Registering Redis therefore bounds cross-replica staleness rather than removing it, and the prefix scan that runs is HybridCacheService.RemoveByPrefixAsync (:219-237, a warn-once no-op without a multiplexer at :221-228). A read that must see a removal everywhere goes through GetFromSharedStoreAsync (:154). The Tier 1 TTL bullet and the Trade-offs bullet now say so; ADR-077 owns the substrate itself.
  2. The interface caveat names both stale comments. Besides the <remarks> sentence anticipating a Redis INCR override (MMCA.Common.Application/Interfaces/ICacheService.cs:106), the member's <summary> opens with "Atomically increments" (:94). Neither describes shipped behavior: the default member, DistributedCacheService's override (MMCA.Common.Infrastructure/Caching/DistributedCacheService.cs:153) and the override that runs with Redis configured, HybridCacheService.IncrementAsync (MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:264, L2-only, remarks at :243-248), are all read-modify-write.
  3. Anchors re-verified against current source: ADC Conference adminBypassRoles at MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:268, its bypass policies at :269-270, :276-283 and :300, NowNextCache at :286, ConferenceCache's AddPolicy at :237-238 and its comment at :232-236; ICacheService.IncrementAsync at MMCA.Common.Application/Interfaces/ICacheService.cs:108, its <remarks> at :103-107; AuthUIService's read-cache clears at MMCA.Common.UI/Services/Auth/AuthUIService.cs:393 (sign-out, inside SignOutLocallyAsync at :379, reached from :101 and :144) and :190 (unrefreshable session). The 2026-08-18 anchors for RegisterOutputCacheEvictionConsumer, RegisterUpcastedIntegrationEventConsumer<TEvent> and the MMCA.Common.OutputCache meter subscription are already re-pointed in the Revision (2026-10-06) and are left as written there.

Revision (2026-10-21)

Re-verified against current source. The two tiers, the substrate selection, the seven-service Redis and hybrid wiring, ADC Conference's eleven-of-twelve bypass count, Store Catalog's four plain policies and the client tier are unchanged. The interface comment the counter trade-off warned about is fixed, two descriptions were corrected, and anchors moved in most cited files.

  1. The ICacheService caveat is retired. The counter trade-off told a reader that the interface's <summary> opened with "Atomically increments" and its <remarks> anticipated a Redis INCR override. Both now match shipped behavior: the <summary> says the member is not atomic in any shipped implementation (MMCA.Common.Application/Interfaces/ICacheService.cs:93-100) and the <remarks> says no shipped implementation overrides it with INCR (:105-111, the sentence at :108-110). The trade-off itself holds: the default member (:112), DistributedCacheService.IncrementAsync (MMCA.Common.Infrastructure/Caching/DistributedCacheService.cs:153) and HybridCacheService.IncrementAsync (MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:326) are all read-modify-write. The Status sentences of 2026-08-23 and the 2026-10-07 item 2 describe the comments as they were then.
  2. Every service declares the NoCache base, the adopters included. Tier 2 read as if only Identity, Sales, Engagement and Notification declared it. ADC Conference (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:231) and Store Catalog (MMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:151) declare it too and add their named policies on top.
  3. Role claim types are matched case-sensitively. The Revision (2026-09-07) says GetRoleValues reads ClaimTypes.Role, role and roles case-insensitively. It matches those three claim types with StringComparison.Ordinal (MMCA.Common/Source/Core/MMCA.Common.Shared/Auth/ClaimsPrincipalExtensions.cs:64-66); only HasRole compares role values case-insensitively (StringComparer.OrdinalIgnoreCase, :77). The policy applies HasRole through Array.Exists in IsBypassedCaller (MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:146-147).
  4. Anchors re-verified against current source: AddCommonHybridCache at MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:141, AddCommonHybridCacheWhenRedisConfigured at :202, its guard at :208-211; the hybrid opt-in calls at ADC Conference Program.cs:204, ADC Identity :139, Store Sales :114 and Store Identity :103; the AddRedisCaching calls at ADC Identity Program.cs:131, Store Sales :105 and Store Identity :94; AddRedisOutputCaching at ADC Conference Program.cs:196; ADC Conference adminBypassRoles at :269, its bypass policies at :270-271, :277-284 and :301, NowNextCache at :287, ConferenceCache's AddPolicy at :238-239 and its comment at :233-237; HybridCacheService LocalCacheDefault at MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:69, the shorter-of rule in WriteOptions at :403-409, RemoveAsync remarks at :253-258, RemoveByPrefixAsync remarks at :263-280 and method at :281-300 (the no-multiplexer warn-once at :283-291), GetFromSharedStoreAsync at :216, IncrementAsync remarks at :303-325; PublicEndpointOutputCachePolicy's QueryKeys = "*" at MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:101, IsCacheableRequest at :139, IsBypassedCaller at :146; AddUIShared's IUiReadCache registration at MMCA.Common.UI/DependencyInjection.cs:77. The tenant vary-by stamp (2026-09-07), the eviction-consumer anchors and the MMCA.Common.OutputCache meter subscription (2026-08-18 and 2026-10-06) sit in historical revisions and are left as written there.

Revision (2026-10-26)

Re-verified against current source. The two tiers, the substrate selection, the seven-service Redis and hybrid wiring (no eighth AddRedisCaching call), the seven NoCache bases, ADC Conference's eleven-of-twelve bypass count, Store Catalog's four plain policies, the counter trade-off and the client tier are unchanged. Only anchors moved, in the seven service Program.cs files and in HybridCacheService, ICacheService and MiddlewarePipelineBuilder.

  1. Anchors re-verified against current source: the hybrid opt-in calls at ADC Conference Program.cs:210, Notification :125, Engagement :122, ADC Identity :145, Store Catalog :114, Sales :120 and Store Identity :109; the AddRedisCaching calls at ADC Conference Program.cs:191, Notification :117, Engagement :114, ADC Identity :137, Store Catalog :95, Sales :111 and Store Identity :100; AddRedisOutputCaching at ADC Conference Program.cs:202 and Store Catalog :105; the NoCache base at ADC Conference Program.cs:237 and Store Catalog :157; ADC Conference adminBypassRoles at :275, its bypass policies at :276-277, :283-290 and :307, NowNextCache at :293, ConferenceCache's AddPolicy at :244-245 and its comment at :239-243; Store Catalog's four policies at Program.cs:158, :159, :165 and :168; the output-cache pipeline step at MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:130-132 (app.UseOutputCache() at :132); HybridCacheService GetFromSharedStoreAsync at MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:217, RemoveAsync remarks at :254-259, RemoveByPrefixAsync remarks at :264-281 and method at :282-301 (the no-multiplexer warn-once at :284-292), IncrementAsync at :327 with remarks at :304-326, and WriteOptions at :402-413 with the shorter-of comparison at :410; ICacheService.IncrementAsync at MMCA.Common.Application/Interfaces/ICacheService.cs:116, its <summary> at :97-104 and its <remarks> at :109-115 (the no-INCR sentence at :112-114). The MMCA.Common.OutputCache meter subscription (2026-08-18, 2026-10-01, 2026-10-06), the eviction-consumer anchors (2026-08-18, 2026-08-23, 2026-08-31) and the tenant vary-by stamp (2026-09-07) sit in historical revisions and are left as written there.

Revision (2026-10-28)

Re-verified against current source. The two tiers, the substrate selection, the seven-service Redis and hybrid wiring (seven AddRedisCaching calls, seven AddCommonHybridCacheWhenRedisConfigured calls, two AddRedisOutputCaching calls), the guarded helper's behavior (it registers the hybrid substrate only when the named connection string is non-empty) and the client tier are unchanged. Only anchors moved, in DependencyInjection.Caching.cs and the ADC Identity Program.cs.

  1. Anchors re-verified against current source: AddCaching at MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:27 (still called from AddInfrastructure at DependencyInjection.cs:140), its CacheSettings options chain at :44-47, AddCommonHybridCache at :157 (the RemoveAll<ICacheService> replacement from :183), and AddCommonHybridCacheWhenRedisConfigured at :218 with its guard block at :224-227; ADC Identity's hybrid opt-in at MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:146 and its AddRedisCaching call at :138. Re-checked and unchanged: the other six hybrid opt-ins (ADC Conference Program.cs:210, Notification :125, Engagement :122, Store Catalog :114, Sales :120, Store Identity :109), the other six AddRedisCaching calls (ADC Conference :191, Notification :117, Engagement :114, Store Catalog :95, Sales :111, Store Identity :100) and AddRedisOutputCaching at ADC Conference :202 and Store Catalog :105. In historical revisions, left as written there: the MMCA.Common.OutputCache meter subscription is now at MMCA.Common.Aspire/Extensions.Telemetry.cs:310, still the sixth of what are now ten chained AddMeter calls (:305-314); RegisterOutputCacheEvictionConsumer is at MMCA.Common.Infrastructure/Messaging/Consumers/IntegrationEventConsumerExtensions.cs:158 and RegisterUpcastedIntegrationEventConsumer<TEvent> at :123; the tenant vary-by stamp reads ITenantContext.TenantId at MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:107 and writes the t key at :110; and GetRoleValues is at MMCA.Common.Shared/Auth/ClaimsPrincipalExtensions.cs:60 (Ordinal claim-type matches at :65-67), HasRole at :76 (OrdinalIgnoreCase at :78).

Revision (2026-11-04)

Common v1.277.0 (Common PR #668) changes Tier 1's substrate and its prefix-invalidation mechanism. Tier 2, the client tier, the seven-service Redis and hybrid wiring and the counter trade-off's conclusion are unchanged.

  1. DistributedCacheService and RedisPrefixScanner are removed. AddCaching registers MemoryCacheService only (MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:78-98), and a host that registers a non-memory IDistributedCache without AddCommonHybridCache fails when ICacheService resolves, with an InvalidOperationException naming the call (:85-91). The memory-or-distributed swap is now a memory-or-hybrid choice, and every first-party service host already made it.
  2. Prefix invalidation is a generation-token write, not a SCAN. HybridCacheService folds the generation token of each : boundary of a key into the key it stores (MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:414-418, the boundaries listed at MMCA.Common.Infrastructure/Caching/CachePrefixGenerations.cs:246), and RemoveByPrefixAsync replaces one token with one StringSetAsync (CachePrefixGenerations.cs:237). Orphaned entries expire on their own TTL. The token keys sit under their own hcg: segment (CachePrefixGenerations.cs:76) and carry no TTL: one short string per distinct invalidated prefix (:43-45).
  3. Outage posture. A failed token read never fails the cache call: it answers with the last token this process knew for the boundary, or the empty baseline for a boundary it never saw, and is not retried for one local cache duration (CachePrefixGenerations.cs:52-66, ReadFailed at :354-358, FallbackToken at :366-367). A known token past its local duration is served while one background read per boundary refreshes it (:37-42, the in-flight map at :108).
  4. The boundary contract. A non-empty prefix must end at : in every store, or RemoveByPrefixAsync throws ArgumentException (MMCA.Common.Infrastructure/Caching/CachePrefixContract.cs:17-27). The caching command decorator logs a rejected prefix at Error and still schedules its delayed re-invalidation (MMCA.Common.Application/UseCases/Decorators/CachingCommandDecorator.cs:76-81, :97).
  5. Why not HybridCache.RemoveByTagAsync. Recorded in ADR-077's Revision (2026-11-04): in Microsoft.Extensions.Caching.Hybrid 10.11.0 each process reads a tag's invalidation time once and never refreshes it (CachePrefixGenerations.cs:17-24).
  6. Anchors re-verified against current source and re-pointed in the Decision and Trade-offs: AddCaching DependencyInjection.Caching.cs:30, its CacheSettings chain :47-50, AddCommonHybridCache :160 (RemoveAll<ICacheService> at :186), the guarded helper :221 (guard :227-230); CacheSettings.DefaultDuration CacheSettings.cs:34, LocalCacheDuration :47, PopulateLockTimeout :62; HybridCacheService.cs LocalCacheDefault :65, GetFromSharedStoreAsync :246, RemoveAsync remarks :285-291, RemoveByPrefixAsync :313-317, IncrementAsync :342 (remarks :319-341), WriteOptions :427-438 (comparison :435); ICacheService.IncrementAsync ICacheService.cs:133 (summary :115-121, remarks :126-132); AddRedisCaching RedisCachingExtensions.cs:59 (no-op :61-64, registrations :66, :67). The seven consumer Program.cs anchors were not re-checked in this pass and stand as the 2026-10-28 Revision records them. The dated revisions above that name DistributedCacheService, RedisPrefixScanner, ScanAndDeleteAsync or SCAN describe the design this revision removes.

Revision (2026-11-17)

The optional client tier recorded by the Revision (2026-09-01) is removed in MMCA.Common v1.301.0 (MMCA.Common #758, the UI drift wave; plan in the workspace Docs/Planning/Drift/UiProjects-plan.md, item C5). Neither server tier changes.

  1. Why. The tier had one adoption, and it failed: Store opted all six UI services in with v1.175.0 and withdrew them the same day (Store #110) after its end-to-end gate failed four workflows on reads up to 60 seconds stale (child-entity writes did not invalidate the parent prefix; cross-service journeys read old values). No consumer adopted it in the eleven weeks after, and adopting it safely needs per-service invalidation rules nobody designed. Shipping an inert capability whose one known use broke the gate is the opposite of keeping the framework simple.
  2. What was removed. IUiReadCache, UiReadCache, UiReadCacheOptions (the UiReadCache configuration section), the optional readCache constructor parameter of EntityServiceBase, AuthUIService and JwtAuthenticationStateProvider, EntityServiceBase.ReadCache and GetCachedAsync<T>(url, cancellationToken, bypassCache).
  3. What callers use instead. EntityServiceBase.SendGetAsync<T>(url, cancellationToken) (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Api/EntityServiceBase.cs:226), the same GET through the retry pipeline; Store's three GetCachedAsync call sites moved to it.
  4. The Decision and Trade-offs now describe the removal (Decision "The client tier was removed", Trade-offs "No client tier, by decision"). The Revisions dated 2026-09-01, 2026-10-01 and 2026-10-06 describe the tier as it stood on their date and are left as written.

Revision (2026-11-23)

Re-verified against current source. The two tiers, the substrate, the invalidation semantics and the counter trade-off are unchanged. What moved is where the services' caching registrations live, and the policy counts in the two output-cache adopters.

  1. The services' Redis and hybrid wiring lives in the composed service host. No ADC or Store service Program.cs calls AddRedisCaching, AddRedisOutputCaching or AddCommonHybridCacheWhenRedisConfigured. All seven are built through builder.AddMmcaServiceHost (ADC Conference Program.cs:82, Engagement :58, Identity :82, Notification :58; Store Catalog :32, Identity :37, Sales :51), and that host calls AddRedisCaching() unconditionally (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:89) and the guarded hybrid helper (:95). The wrapper holds the only AddRedisDistributedCache / AddRedisClient calls (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Caching/RedisCachingExtensions.cs:76-77). The Decision (Tier 1) and the multiplexer trade-off now say so; the earlier Status sentences that name per-service wrapper calls describe the state on their date.
  2. The output-cache registration and its NoCache base are the host's. The host registers AddOutputCache once with AddBasePolicy(NoCache) and then invokes the service's ConfigureOutputCache callback (ServiceHostBuilderExtensions.cs:110-114, base at :112); ADC Conference (Program.cs:136) and Store Catalog (Program.cs:57) supply only named policies.
  3. The Redis output-cache store is opted into by a host option. ADC Conference (Program.cs:129) and Store Catalog (Program.cs:53) set UseRedisOutputCaching = true (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/MmcaServiceHostOptions.cs:55), and the host calls AddRedisOutputCaching() only when it is set (ServiceHostBuilderExtensions.cs:90-93). No other service sets it. The wrapper still no-ops on a blank connection string (RedisCachingExtensions.cs:106-109).
  4. Store Catalog has three public-read policies, not four, all on the plain overload (MMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:59-60, :64-65, :68-69).
  5. ADC Conference bypasses privileged callers on ten of its eleven public-read policies. Nine use the role-bypass overload (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:175, :193-199, :216); the sessions policy constructs PublicEndpointOutputCachePolicy directly with a permission bypass for ConferencePermissions.SessionAssetsManage as well (:186-192), through the four-argument constructor (MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:92) that no AddPublicEndpointPolicy overload exposes. NowNextCache (:202) is the one without a bypass, and ConferenceCache (:143-144) is the twelfth named policy, not the thirteenth.
  6. The eviction handler's non-reuse reason no longer holds. The Revision (2026-08-18) says the handler hand-rolls its swallow-log-count shape because the API package cannot reach BestEffort without a layer-crossing reference. The handler does still hand-roll it, counting on its own MMCA.Common.OutputCache meter (MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/OutputCacheEvictionHandler.cs:56, :60; OutputCacheMetrics.cs:19), but the same package already calls BestEffort.ExecuteAsync for the controller-side TryEvictTagsAsync helper (OutputCacheEvictionExtensions.cs:78, :86), on the MMCA.Common.BestEffort meter. What keeps the handler apart is its dedicated eviction-failure counter, not a missing reference; ADR-096 records the same finding.
  7. Anchors re-verified against current source: AddCaching call MMCA.Common.Infrastructure/DependencyInjection.cs:141; AddCommonHybridCache DependencyInjection.Caching.cs:162 (RemoveAll<ICacheService> :188, multiplexer resolve :193), the guarded helper :226 (guard :232-235); CachePrefixGenerations.cs key builder :281; HybridCacheService.cs LocalCacheDefault :71, GetFromSharedStoreAsync :266, RemoveAsync remarks and body :305-316, RemoveByPrefixAsync :333-337 (EnsureBoundary :335), IncrementAsync :362 (remarks :339-361), WriteOptions :458-469 (default-duration fallback :460, comparison :466); RedisCachingExtensions.cs AddRedisCaching :69 (no-op :71-74), AddRedisOutputCaching :103 (AddStackExchangeRedisOutputCache :111); MiddlewarePipelineBuilder.cs:139-141, MiddlewarePipelineStepNames.cs:71; PublicEndpointOutputCachePolicy.cs class :47, CacheRequestAsync :106-143, IsCacheableRequest :165, IsBypassedCaller :172; ADC Conference adminBypassRoles :174, ConferenceCache rationale :138-142.

Revision (2026-11-30)

MMCA.Common v1.324.0 (MMCA.Common/CHANGELOG.md:17, :43). Tier 1 (ICacheService and its backing stores) and Tier 2 (the output-cache edge) are unchanged. What changed is whether the ADR-014 caching decorators, this substrate's in-pipeline consumer, run at all, and how long a waiter queues behind a populate.

  1. Query caching is a host opt-in. AddApplicationDecorators() adds CachingCommandDecorator and CachingQueryDecorator to the pipeline only when the host called AddQueryCaching() first, before AddMmcaApplicationPipeline(...) or inside its callback; after the pipeline seals the call throws (MMCA.Common/Source/Core/MMCA.Common.Application/DependencyInjection.cs:153-156, :165, :177; AddQueryCaching at :214-221, its contract at :198-213). Without it IQueryCacheable and ICacheInvalidating are inert markers: no query result is served from or written to the cache, and a write makes no ICacheService call. The reason is cost, not correctness: MMCA.ADC and MMCA.Store declare no IQueryCacheable query, yet every ICacheInvalidating command bumped a prefix generation and scheduled a delayed re-eviction against keys nothing populated. Neither calls AddQueryCaching(), and their order tests say so (MMCA.ADC/Tests/Architecture/MMCA.ADC.Architecture.Tests/Cqrs/DecoratorPipelineOrderTests.cs:28, MMCA.Store/Tests/Architecture/MMCA.Store.Architecture.Tests/Cqrs/DecoratorPipelineOrderTests.cs:28). MMCA.Helpdesk, the consumer with cacheable queries, opts in in its v1.324.0 upgrade (pull request #261, open when this revision was written; MMCA.Helpdesk/Source/Hosts/MMCA.Helpdesk.Web/Program.cs:134 on that branch). The cache itself is still registered separately by Infrastructure's AddCaching, which other consumers of ICacheService (login counters, OAuth state, idempotency records) keep using either way.
  2. The populate lock waits five seconds by default. QueryCachePipelineSettings.DefaultPopulateLockTimeout is five seconds (MMCA.Common/Source/Core/MMCA.Common.Application/Settings/QueryCachePipelineSettings.cs:30, the property at :43), and CacheSettings.PopulateLockTimeout defaults to the same value (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Caching/CacheSettings.cs:64); both were unbounded. A waiter that exhausts the wait runs the handler itself, uncached, and the request holding the lock still populates the entry (MMCA.Common/Source/Core/MMCA.Common.Application/UseCases/Decorators/CachingQueryDecorator.cs:84-96), so the setting bounds latency and never decides success. Zero or a negative value still means no bound (QueryCachePipelineSettings.cs:40-41).

Revision (2026-12-03)

MMCA.Common v1.331.0. One substrate correction; no decision changed.

  1. CacheOptions is the duration alone. The DistributedCacheEntryOptions-typed default and its factory are removed; CacheOptions.DefaultDuration (CacheOptions.cs:17) is the class's only member, and the stores apply the configured CacheSettings.DefaultDuration to an entry written without an expiration (MemoryCacheService.cs:138, HybridCacheService.cs:410). The Tier 1 default-TTL bullet is re-anchored to match: CacheSettings.cs:40-41, :55, :67-68, :84; DependencyInjection.Caching.cs:53-56. The value is still 30 seconds.