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) exposesGetAsync/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 fromAddInfrastructureatMMCA.Common.Infrastructure/DependencyInjection.cs:141) registersMemoryCacheServicewithTryAddSingleton(DependencyInjection.Caching.cs:79-99). The shared-store substrate isHybridCacheService(L1 in-process plus L2 distributed, ADR-077), registered byAddCommonHybridCache(...)(MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:162), which replaces the registration this call made (RemoveAll<ICacheService>at:188). A host that registers a realIDistributedCache(one that is not the in-memoryMemoryDistributedCache) without that call does not fall back to memory: resolvingICacheServicethrows anInvalidOperationExceptionnamingAddCommonHybridCache(: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 asInProcessMessageBusvsBrokerMessageBus(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 throughbuilder.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). SoHybridCacheServiceis the liveICacheServicewherever Redis is configured, andMemoryCacheServiceis what runs where it is not: local runs, tests, and any host that wires no Redis. - Prefix invalidation, implemented per store.
IMemoryCachehas no key-enumeration API, soMemoryCacheServicetracks live keys in aConcurrentDictionary(kept in sync by a post-eviction callback) to supportRemoveByPrefixAsync.HybridCacheServicenever 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, andRemoveByPrefixAsyncreplaces 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 RedisSETunder{namespace}hcg:{prefix}, whatever the size of the keyspace (CachePrefixGenerations.cs:217-238, the write at:237, the key built at:281); when noIConnectionMultiplexeris 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, otherwiseArgumentException(MMCA.Common.Infrastructure/Caching/CachePrefixContract.cs:17-27, called atMemoryCacheService.cs:146andHybridCacheService.cs:335), the shape everyICacheInvalidating.CachePrefixtakes (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 bareTimeSpanand 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, theCache:DefaultDurationkey, at least one second:40) defaults toCacheOptions.DefaultDuration, is bound and validated at startup byAddCachingwhen 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 forHybridCacheService(: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 byCache:LocalCacheDuration(30 seconds by default,HybridCacheService.cs:71; the L1 lifetime is the shorter of the entry TTL and that ceiling,WriteOptionsat: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.APIcallsapp.UseOutputCache()in the shared middleware pipeline, which is a builder of named steps rather than a run of inline calls: the step is registered atMMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:139-141under the nameMiddlewarePipelineStepNames.OutputCache(MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineStepNames.cs:71). The pipeline ships no policies. The composed service host registersAddOutputCache(...)once for every service built on it, with aNoCachebase policy, then hands the options to the service's ownConfigureOutputCachecallback (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:110-114, the base at:112), so all seven services carry theNoCachebase and no service registersAddOutputCacheitself. 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 anAuthorizationheader. So the adopters do not cache only anonymous traffic: they register their public-read policies throughOutputCacheOptions.AddPublicEndpointPolicy(name, expiration, tags)(MMCA.Common.API/Caching/OutputCacheOptionsExtensions.cs:20), backed byPublicEndpointOutputCachePolicy(MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:47), whoseCacheRequestAsynccaches GET/HEAD regardless of the caller's auth state (MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:106-143, via the private helpersIsCacheableRequest/IsBypassedCalleratMMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:165and: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.
AddPublicEndpointPolicyhas 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:175and the permission check at:188), which noAddPublicEndpointPolicyoverload exposes, so a host that needs it registers the policy with the built-inAddPolicy(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 anadminBypassRolesarray projected fromConferenceReadAudience.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-199and:216); the tenth, the sessions policy (ConferenceCacheTags.SessionsPolicy), constructs the policy directly so it can also bypass a caller holdingConferencePermissions.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-inAddPolicy(:143-144), not as a public-read policy: it keeps the built-in default semantics (no caching for anAuthorization-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.
AddOutputCachedefaults 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 wrapperbuilder.AddRedisOutputCaching()(MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Caching/RedisCachingExtensions.cs:103), which holds the framework's singleAddStackExchangeRedisOutputCache(...)call (:111) and no-ops when the named connection string is blank (:106-109). They reach it by setting the service-host optionUseRedisOutputCaching = 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.AddOutputCacheregisters its store withTryAdd, 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 throughIDistributedCache, 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 formerGetCachedAsynccallers call it. TheUiReadCacheconfiguration 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
ICacheServiceas the only thing application code sees lets the deployment decide memory vs distributed. The auto-swap (presence of a realIDistributedCache) 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 theIConnectionMultiplexerthe 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 withDisableHealthChecks = true, and no-ops when the named connection string is blank. The wrapper exists because the raw Aspire integrations register an untaggedStackExchange.Redishealth check, which readiness therefore includes, and against Azure Managed Redis that check issuesCLUSTER 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 throughAddMmcaServiceHost(Tier 1 above lists the seven call sites). OnlyAddCommonHybridCache(), which has no guard of its own, is reached conditionally, through the guardedAddCommonHybridCacheWhenRedisConfigured(...)helper the same host calls (ServiceHostBuilderExtensions.cs:95). No serviceProgram.csin either repo'sSource/tree callsAddRedisCaching, and the wrapper holds the onlyAddRedisDistributedCache/AddRedisClientcalls (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, withinCache: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 throughGetFromSharedStoreAsync(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.IncrementAsyncis a default interface member implemented as a read-modify-write (MMCA.Common.Application/Interfaces/ICacheService.cs:133), whichMemoryCacheServiceinherits. With Redis configured the override that runs isHybridCacheService.IncrementAsync(MMCA.Common.Infrastructure/Caching/HybridCacheService.cs:362), also a read-modify-write rather than RedisINCR, 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):INCRwrites a Redis string, whileStackExchangeRedisCache(the L2 underHybridCache) stores every entry as a Redis hash (absexp/sldexp/data, read back withHMGET). AnINCR-written counter therefore makes the next read of that key fail withWRONGTYPE, 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 RedisINCR, for the storage-format reason above (:126-132, the sentence at:129-131). - Output caching is opt-in per service. The composed host registers
AddOutputCachewith theNoCachebase for every service (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:110-114), so a read-heavy service that supplies noConfigureOutputCachecallback with a real named policy (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/MmcaServiceHostOptions.cs:60) gets no edge caching (theNoCachebase 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 setsUseRedisOutputCaching(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.
- Tier-1 keys are caller-scoped where the result is caller-scoped (SEC-Common-19 /
SEC-Common-37).
CachingQueryDecoratorcomposesTenantCacheKey.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 implementsIUserScopedRequest(MMCA.Common/Source/Core/MMCA.Common.Application/Users/IUserScopedRequest.cs:8); theISharedQueryCachemarker (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. - The public output-cache key varies by resolved tenant (SEC-Common-46).
PublicEndpointOutputCachePolicystampsITenantContext.TenantIdintoCacheVaryByRulesunder thetkey (MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:50,:102-105), mirroring thet:{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. - 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, overGetRoleValuesat:59, which readsClaimTypes.Role,roleandrolescase-insensitively), applied atPublicEndpointOutputCachePolicy.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. - The cache key prefix is namespaced per application.
Cache:KeyPrefixleft 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.
Related
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.
- 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 insideDistributedCacheServicerather than throughRedisCacheOptions.InstanceNamedeliberately:InstanceNameis prepended below this abstraction, where prefix invalidation cannot see it, so the SCAN inRemoveByPrefixAsyncwould look forproduct:*while the stored keys weresvc:product:*and evict nothing, silently. Applying it here keeps get, set, remove, the SCAN pattern and the Redis counter working from one key shape.MemoryCacheServiceignores it: its keyspace is private to the process by construction. - Prefix invalidation survives an overwrite.
MemoryCacheServicetracks live keys in a side dictionary becauseIMemoryCachecannot enumerate, and its post-eviction callback removed the key for every eviction reason.IMemoryCachequeues 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 toRemoveByPrefixAsyncand clearable only by its TTL. The callback now skipsEvictionReason.Replaced; genuine evictions still clean up. 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, andDistributedCacheServicedeliberately keeps that shape rather than reaching for RedisINCR: 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.
- The
IncrementAsyncentry above was wrong. It described a RedisINCRoverride. There is no such override, and none is intended: both the default interface member andDistributedCacheService's implementation are read-modify-write, because a counter written byINCR(a Redis string) cannot be read back by the hash-shapedStackExchangeRedisCachepath that consults it. The resulting non-atomicity is recorded in Trade-offs as the accepted position, not as an open defect. - 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.
- Refreshed line anchors for
AddCachingand 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.
- Tier 2. Store Catalog's
AddStackExchangeRedisOutputCache(...)is atProgram.cs:90; the previously cited:88had become a line inside the comment above the call. ADC Conference'sProgram.cs:129was re-checked and still holds. - Trade-offs, the seven paired Redis registrations. Three moved: ADC Identity to
Program.cs:108,113(from:109,114), Store Catalog toProgram.cs:75,80(from:73,78), and Store Identity toProgram.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.AddCachingatMMCA.Common.Infrastructure/DependencyInjection.cs:149is also unchanged, as are the Tier 2 policy anchors inMMCA.Common.APIand the counter anchors inICacheService/DistributedCacheService. - 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.
AddCaching. Now atMMCA.Common.Infrastructure/DependencyInjection.cs:150(from:149); the previous line is the<returns>doc comment above the declaration, not the declaration itself.- Tier 2. Store Catalog's
AddStackExchangeRedisOutputCache(...)moved again, toProgram.cs:96(from the 2026-07-28 anchor of:90, itself a correction of an earlier:88). ADC Conference's moved toProgram.cs:135(from:129). - 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 toProgram.cs:105,110(from:99,104), Engagement toProgram.cs:94,99(from:88,93), Identity toProgram.cs:114,119(from:108,113); Store Catalog toProgram.cs:81,86(from:75,80), Sales toProgram.cs:82,87(from:76,81), Identity toProgram.cs:85,90(from:79,84). - Counter anchors.
DistributedCacheService'sIncrementAsyncoverride is now atDistributedCacheService.cs:175-181(from:122-128), and the storage-format-mismatch<remarks>documenting it is now atDistributedCacheService.cs:156-174(from:104-121). The old line range for both now falls inside the unrelatedRemoveByPrefixAsync/ScanAndDeleteAsyncSCAN logic. - 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.
AddCaching. Now atMMCA.Common.Infrastructure/DependencyInjection.cs:157(from:150); line 150 is now the closing brace of the preceding method. The registration behavior it describes (DistributedCacheServicewhen a real, non-MemoryDistributedCacheIDistributedCacheis present,MemoryCacheServiceotherwise) is unchanged.- 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)). - Tier 2. ADC Conference's
AddStackExchangeRedisOutputCache(...)moved toProgram.cs:147(from:135) and Store Catalog's toProgram.cs:98(from:96). - Trade-offs, the seven paired Redis registrations. Six moved: ADC Conference to
Program.cs:131,136(from:119,124), Notification toProgram.cs:106,111(from:105,110), Engagement toProgram.cs:96,101(from:94,99), Identity toProgram.cs:123,128(from:114,119); Store Catalog toProgram.cs:83,88(from:81,86), Identity toProgram.cs:87,92(from:85,90). Store Sales was re-checked and is unchanged at:82,87. The Tier 2 policy anchors inMMCA.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-174and:175-181) were re-checked and are unchanged. - 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:
- A third substrate, opted into rather than auto-selected.
HybridCacheService(L1 in-process plus L2 distributed,Microsoft.Extensions.Caching.Hybrid) joinsMemoryCacheServiceandDistributedCacheService.AddCaching()'s presence-of-a-real-IDistributedCacheswap 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. - The counter trade-off above is generalized into a keyspace rule. The
WRONGTYPEincident documented in Trade-offs (a RedisINCRstring read back by the hash-shapedStackExchangeRedisCachepath) 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-writeIncrementAsyncposition is unchanged, and the hybrid implementation bypasses L1 on both legs precisely to keep it unchanged. - 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.
- The 30-second default now has a named home,
CacheOptions.DefaultDuration. Tier 1 described the default TTL as a literalTimeSpan.FromSeconds(30)inside aDistributedCacheEntryOptions.CacheOptionshas since gained aDefaultDurationproperty (CacheOptions.cs:17), a bareTimeSpanadded for the ADR-077HybridCacheService, whose entry options areHybridCacheEntryOptionsrather thanDistributedCacheEntryOptionsand so could not have reused that entry-options value without hard-coding the figure a second time. The entry-options value then readAbsoluteExpirationRelativeToNow = 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. - 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 forAddRedisDistributedCache/AddRedisClientreturns exactly these fourteen call sites, so "all seven services" is a verified count, not an assumption. The Trade-offs entry now says so. AddCaching. Now atMMCA.Common.Infrastructure/DependencyInjection.cs:164(from:157); line 157 is now the closing brace of the preceding method.- Tier 2.
app.UseOutputCache()moved toWebApplicationExtensions.cs:111(from:104). ADC Conference'sAddStackExchangeRedisOutputCache(...)moved toProgram.cs:156(from:147) and Store Catalog's toProgram.cs:117(from:98). - Trade-offs, the seven paired Redis registrations. All seven moved: ADC Conference to
Program.cs:140,145(from:131,136), Notification toProgram.cs:114,119(from:106,111), Engagement toProgram.cs:111,116(from:96,101), Identity toProgram.cs:131,136(from:123,128); Store Catalog toProgram.cs:94,99(from:83,88), Sales toProgram.cs:111,116(from:82,87), Identity toProgram.cs:100,105(from:87,92). - Counter anchors.
DistributedCacheService'sIncrementAsyncis now atDistributedCacheService.cs:127-133(from:175-181) and the storage-format-mismatch<remarks>documenting it atDistributedCacheService.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:57and the Tier 2 policy anchors (OutputCacheOptionsExtensions.cs:20,PublicEndpointOutputCachePolicy.cs:35,:71-75,:109-113) were re-checked and are unchanged. - 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.failedhas 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.
OutputCacheEvictionRequestedis 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.
- The counter trade-off now names the contradiction a reader will hit.
ICacheService's<remarks>onIncrementAsyncsays that backing stores which can do better with RedisINCRoverride 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 noINCRoverride 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. - Tier 2's
UseOutputCachecall has a new home, and a different shape of home.app.UseOutputCache()is no longer an inline call inMMCA.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 atMMCA.Common.API/Startup/MiddlewarePipelineBuilder.cs:138, named byMiddlewarePipelineStepNames.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. - The eviction event's method surface gained an ADR-090 sibling.
RegisterOutputCacheEvictionConsumermoved toIntegrationEventConsumerExtensions.cs:108-110(from:68-70) becauseRegisterUpcastedIntegrationEventConsumer<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. - Remaining anchors.
AddCachingis now atMMCA.Common.Infrastructure/DependencyInjection.cs:177(from:164).OutputCacheEvictionRequested's declaration is at:27andTagsat:35(from:23and:31), both pushed down four lines by a Frozen-contract-candidate paragraph added to the doc comment.BaseIntegrationEvent.SchemaVersionis at:32(from:22), likewise behind added doc text.ICacheService'sIncrementAsyncdeclaration is at:59(from:57;:57is now the last line of the<remarks>discussed in item 1). Re-checked and unchanged:CacheOptions.cs:17and:22-25, both adopters'AddStackExchangeRedisOutputCachecalls and all seven paired Redis registrations,DistributedCacheService.cs:108-126and:127-133, the Tier 2 policy anchors (OutputCacheOptionsExtensions.cs:20,PublicEndpointOutputCachePolicy.cs:35,:71-75,:109-113),OutputCacheEvictionExtensions.cs:32and:36-38,OutputCacheEvictionHandler.cs:32and:44-63,OutputCacheMetrics.cs:19and:29-37, andMMCA.Common.Aspire/Extensions.cs:169. - 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.
AddCaching. Now atMMCA.Common.Infrastructure/DependencyInjection.cs:215(from:177); line 177 is now insideAddInfrastructure, at itsIOutboxSignalregistration. The presence-of-a-real-IDistributedCacheswap it describes is unchanged.CacheOptions.DefaultDurationis atCacheOptions.cs:23(from:17, now a line of the doc comment above it) and the entry-options value'sAbsoluteExpirationRelativeToNow = DefaultDurationat:28-31(from:22-25). The figure is still 30 seconds and still has exactly one home.- Tier 2. ADC Conference's
AddStackExchangeRedisOutputCache(...)is atProgram.cs:140(from:156) and Store Catalog's atProgram.cs:96(from:117). - Trade-offs, the seven paired Redis registrations. All seven moved up: ADC Conference to
Program.cs:124,129(from:140,145), Notification toProgram.cs:98,103(from:114,119), Engagement toProgram.cs:95,100(from:111,116), Identity toProgram.cs:116,121(from:131,136); Store Catalog toProgram.cs:73,78(from:94,99), Sales toProgram.cs:89,94(from:111,116), Identity toProgram.cs:78,83(from:100,105). The 2026-08-14 exhaustiveness check still holds: a sweep of both repos'Source/trees forAddRedisDistributedCache/AddRedisClientreturns these same fourteen call sites and no eighth service. - Counter anchors.
DistributedCacheService'sIncrementAsyncoverride is now atDistributedCacheService.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 unrelatedRemoveByPrefixAsync(its no-multiplexer warning and Redis SCAN delete). The read-modify-write behavior and the reason for it are unchanged, andICacheService.cs:54-57/:59were re-checked and still hold, so item 1 of the 2026-08-23 entry stands as written. - The eviction event.
OutputCacheEvictionRequested's declaration is at:29andTagsat:37(from:27and:35), both pushed down two lines by the[EventName("Common.OutputCacheEvictionRequested.v1")]attribute now sitting on the type (:28) and theusingit needs (:1). Re-checked and unchanged:IntegrationEventConsumerExtensions.cs:108-110and:78-90, and the Tier 2 policy anchors (OutputCacheOptionsExtensions.cs:20,PublicEndpointOutputCachePolicy.cs:35,:71-75,:109-113). - 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.
- The eviction registration.
AddOutputCacheEvictionHandler()is now atMMCA.Common.API/Caching/OutputCacheEvictionExtensions.cs:111(from:32) and itsTryAddEnumerablecall at:115-117(from:36-38). The class itself is still the head of the file (:27); what moved the members is a secondextension(T)block added above theextension(IServiceCollection services)one (:36and:95respectively), holding the multi-tag eviction helpersEvictTagsAsync(:49) and its best-effort siblingTryEvictTagsAsync(:78) that a mutating controller calls after a write, plus theEvictOperationPrefixconst they name their operations from (:34). Twoextension(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. - 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(thecache.eviction.failedinstrument plus its recorder), andMMCA.Common.Aspire/Extensions.cs:169(the meter subscription, which is the SIXTH of the seven chainedAddMetercalls, not the fifth: they begin atMMCA.Common.Outboxon:164and 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. - The output-cache step name was cited one line high, and always had been.
MiddlewarePipelineStepNames.OutputCacheis declared atMMCA.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, theapp.UseOutputCache()step itself, was re-read and holds. - 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'sQueryKeys = "*"(PublicEndpointOutputCachePolicy.cs:81), a default TTL plus longest-prefix per-route overrides (UiReadCacheOptions.cs:32and: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 byAddUIShared(MMCA.Common.UI/DependencyInjection.cs:57) and still opt-in per service, through an optional constructor parameter that defaults tonull(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. - 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.
- Redis is wired through framework wrappers now, not by each host. Neither repo calls Aspire's
AddRedisDistributedCache/AddRedisClient/AddStackExchangeRedisOutputCacheany more. All three calls live once, inMMCA.Common.Aspire.Caching.RedisCachingExtensions(MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Caching/RedisCachingExtensions.cs:29), behindAddRedisCaching()(:57, registering the cache at:64and the client at:65) andAddRedisOutputCaching()(:91, the singleAddStackExchangeRedisOutputCachecall 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 untaggedStackExchange.Redischeck that readiness includes, it issuesCLUSTER 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. HybridCacheServiceis 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 callAddCommonHybridCache()(MMCA.Common.Infrastructure/DependencyInjection.cs:340) inside their redis-connection-string conditional, soDistributedCacheServiceis the liveICacheServicein 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.- 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-244on 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. - Three cited files moved into sub-folders.
MiddlewarePipelineBuilder.csandMiddlewarePipelineStepNames.csare underMMCA.Common.API/Startup/Pipeline/(both line anchors,:138and:65, still hold).EntityServiceBase.csis underMMCA.Common.UI/Services/Api/(all its line anchors still hold).IntegrationEventConsumerExtensions.csis underMMCA.Common.Infrastructure/Messaging/Consumers/(:108-110and:78-90still hold). Only the paths changed; the live sections carry the new ones. - Line anchors.
AddCachingis atMMCA.Common.Infrastructure/DependencyInjection.cs:229(from:215, now a comment line insideAddInfrastructure), called fromAddInfrastructureat:131.DistributedCacheService'sIncrementAsyncoverride 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'sTryAddScopedis atMMCA.Common.UI/DependencyInjection.cs:61(from:57, now blank;:56is theTimeProvider.Systemregistration it depends on).AuthUIService's twoClear()calls are at:130and:159(from:127and:156). TheMMCA.Common.OutputCachemeter subscription is atMMCA.Common.Aspire/Extensions.cs:204(from:169); the chain now runs:199-205and OutputCache is still the sixth of seven. Re-checked and unchanged:CacheOptions.cs:23and:28-31,ICacheService.cs:54-57and:59, the Tier 2 policy anchors (PublicEndpointOutputCachePolicy.cs:35,:71-75,:81,:109-113), the wholeIUiReadCache/UiReadCache/UiReadCacheOptionsset, andEntityServiceBase's:47,:58,:229,:241,:248,:262-264,:281and:285. - The client tier is still adopted by no app. A search of all four repositories finds
IUiReadCacheonly in MMCA.Common's own source and tests, so the 2026-09-01 entry's inventory claim stands. - 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.
- Store calls both Redis wrappers unconditionally, as ADC does.
AddRedisCaching()andAddRedisOutputCaching()already no-op on a blank connection string (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Caching/RedisCachingExtensions.cs:59and:94), so an outer connection-string branch around them in a host did nothing. The three Store services now call them top-level (CatalogMMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:88and:98, Sales.../MMCA.Store.Sales.Service/Program.cs:103, Identity.../MMCA.Store.Identity.Service/Program.cs:92), and both repositories wire Redis one way. OnlyAddCommonHybridCache(), 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. - ADC Conference registers twelve public-read policies, and eleven take the bypass list.
BookmarkCountsCachepassesadminBypassRoles(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. - Line anchors.
AddCachingis declared in the partial fileMMCA.Common.Infrastructure/DependencyInjection.Caching.cs:26and called fromAddInfrastructureatDependencyInjection.cs:134;AddCommonHybridCacheis atDependencyInjection.Caching.cs:137. The sevenAddCommonHybridCache()calls are at ADC Conference:203, Notification:119, Engagement:113, Identity:135, Store Catalog:109, Sales:114and Identity:103. The sevenAddRedisCaching()calls are at ADC Conference:183, Notification:109, Engagement:103, Identity:125, Store Catalog:88, Sales:103and Identity:92, and the twoAddRedisOutputCaching()calls at ADC Conference:193and Store Catalog:98. Store Catalog's four policies are atProgram.cs:154,:155,:161and:164, and ADC Conference'sadminBypassRolesarray at:267. Re-checked and unchanged:RedisCachingExtensions.cs:29,:57,:64,:65,:91,:99andOutputCacheOptionsExtensions.cs:20and:34. The exhaustive sweep still holds: both repos'Source/trees carry exactly these nine wrapper calls and no directAddRedisDistributedCache/AddRedisClient/AddStackExchangeRedisOutputCachecall.
Revision (2026-10-01)
One wiring correction, one recorded client-tier detail, and a line-anchor re-verification. No decision and no rationale changed.
- 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 callsAddCommonHybridCache()(:139) only when theredisconnection string is non-empty (:206-208). The outcome the 2026-09-25 entry recorded is unchanged (HybridCacheServicewherever Redis is configured, the memory-or-distributed swap elsewhere); only where the guard lives moved. Call sites: ADC ConferenceProgram.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. - The client tier's store is generation-checked.
IUiReadCachegained aGenerationmember (MMCA.Common.UI/Services/Caching/IUiReadCache.cs:40) and aSetoverload taking it (:70).GetCachedAsynccaptures the generation before the GET (EntityServiceBase.cs:261) and stores through that overload (:268), andUiReadCachedrops the value when anInvalidatePrefixorClearmoved 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 Storeorigin/maincarry no reference toIUiReadCacheunderSource/. - Line anchors.
MiddlewarePipelineBuilder.cs:132-133(from:138);PublicEndpointOutputCachePolicy.cs:44(from:35),CacheRequestAsyncat:81-87(from:71-75),QueryKeys = "*"at:96(from:81), the helpers at:134and:141(from:109-113); the four Store Catalog policies atProgram.cs:151,:152,:158,:161; ADC Conference'sadminBypassRolesat:265, its bypass policies at:266-280and:295,NowNextCacheat:283, andAddRedisOutputCaching()at:194; ADCAddRedisCaching()at Conference:184, Notification:110, Engagement:104;ICacheService.IncrementAsyncat:105with theINCRremark at:103;DistributedCacheService's override at:153and its<remarks>at:134-152;IUiReadCachemembers at:50,:59,:78,:85;MMCA.Common.UI/DependencyInjection.cs:63;UiReadCache.cs:163-178with the comparison at:170;EntityServiceBase.cs:266-269,:285and:289;AuthUIService.cs:352(sign-out) and:162(unrefreshable session). TheMMCA.Common.OutputCachemeter subscription cited in the Revision (2026-08-18) is now in the partial fileMMCA.Common.Aspire/Extensions.Telemetry.cs:312, the sixth of nine chainedAddMetercalls (:307-315). Re-checked and unchanged:DependencyInjection.Caching.cs:26,DependencyInjection.cs:134,CacheOptions.cs:23,MiddlewarePipelineStepNames.cs:65,OutputCacheOptionsExtensions.cs:20and:34,RedisCachingExtensions.cs:57,:59,:64,:65,:91,:94,:99, ADC Identity:125and the three StoreAddRedisCaching()calls (:88,:103,:92) and Store Catalog'sAddRedisOutputCaching()at:98.
Revision (2026-10-06)
Three content corrections plus a line-anchor re-verification. No decision changed.
- The client tier invalidates after any write that may have landed.
InvalidateOnSuccessno 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. - The default TTL is host-configurable.
CacheSettings.DefaultDuration(MMCA.Common.Infrastructure/Caching/CacheSettings.cs:32, keyCache:DefaultDuration) defaults toCacheOptions.DefaultDuration, is bound byAddCaching(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. - ADC Conference's count is scoped to its public-read policies. Eleven of its twelve
AddPublicEndpointPolicyregistrations take the bypass list; a thirteenth named policy,ConferenceCache(MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:236), is a plain built-inAddPolicybecause a permission-gated controller also references it. Tier 2 now says so. - Line anchors re-verified against current source.
AddCachingis called atDependencyInjection.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 sevenAddRedisCaching()calls at ADC Conference:185, Notification:111, Engagement:108, Identity:130, Store Catalog:89, Sales:104, Identity:93; the twoAddRedisOutputCaching()calls at ADC Conference:195and Store Catalog:99. Store Catalog's four policies are at:152,:153,:159,:162; ADC Conference'sadminBypassRolesat:266, its bypass policies at:267-268,:274-281and:298,NowNextCacheat:284.MMCA.Common.UI/DependencyInjection.cs:76;EntityServiceBase.cskey 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:RegisterOutputCacheEvictionConsumeris atMMCA.Common.Infrastructure/Messaging/Consumers/IntegrationEventConsumerExtensions.cs:158-160andRegisterUpcastedIntegrationEventConsumer<TEvent>at:123-140(now also taking an optional endpoint-configuration callback), and theMMCA.Common.OutputCachemeter subscription is atMMCA.Common.Aspire/Extensions.Telemetry.cs:312. Re-checked and unchanged:DependencyInjection.Caching.cs:26,:139,:200,:206-208,CacheOptions.cs:23and:28-31,RedisCachingExtensions.cs:57,:59,:64,:65,:91,:94,:99, andEntityServiceBase.cs:47and: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.
- 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 itsRemoveAsyncandRemoveByPrefixAsyncclear L2 and this process's L1 only: other replicas' L1 copies keep serving the removed value for up toCache: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-195and: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 isHybridCacheService.RemoveByPrefixAsync(:219-237, a warn-once no-op without a multiplexer at:221-228). A read that must see a removal everywhere goes throughGetFromSharedStoreAsync(:154). The Tier 1 TTL bullet and the Trade-offs bullet now say so; ADR-077 owns the substrate itself. - The interface caveat names both stale comments. Besides the
<remarks>sentence anticipating a RedisINCRoverride (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. - Anchors re-verified against current source: ADC Conference
adminBypassRolesatMMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:268, its bypass policies at:269-270,:276-283and:300,NowNextCacheat:286,ConferenceCache'sAddPolicyat:237-238and its comment at:232-236;ICacheService.IncrementAsyncatMMCA.Common.Application/Interfaces/ICacheService.cs:108, its<remarks>at:103-107;AuthUIService's read-cache clears atMMCA.Common.UI/Services/Auth/AuthUIService.cs:393(sign-out, insideSignOutLocallyAsyncat:379, reached from:101and:144) and:190(unrefreshable session). The 2026-08-18 anchors forRegisterOutputCacheEvictionConsumer,RegisterUpcastedIntegrationEventConsumer<TEvent>and theMMCA.Common.OutputCachemeter 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.
- The
ICacheServicecaveat is retired. The counter trade-off told a reader that the interface's<summary>opened with "Atomically increments" and its<remarks>anticipated a RedisINCRoverride. 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 withINCR(: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) andHybridCacheService.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. - Every service declares the
NoCachebase, 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. - Role claim types are matched case-sensitively. The Revision (2026-09-07) says
GetRoleValuesreadsClaimTypes.Role,roleandrolescase-insensitively. It matches those three claim types withStringComparison.Ordinal(MMCA.Common/Source/Core/MMCA.Common.Shared/Auth/ClaimsPrincipalExtensions.cs:64-66); onlyHasRolecompares role values case-insensitively (StringComparer.OrdinalIgnoreCase,:77). The policy appliesHasRolethroughArray.ExistsinIsBypassedCaller(MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:146-147). - Anchors re-verified against current source:
AddCommonHybridCacheatMMCA.Common.Infrastructure/DependencyInjection.Caching.cs:141,AddCommonHybridCacheWhenRedisConfiguredat:202, its guard at:208-211; the hybrid opt-in calls at ADC ConferenceProgram.cs:204, ADC Identity:139, Store Sales:114and Store Identity:103; theAddRedisCachingcalls at ADC IdentityProgram.cs:131, Store Sales:105and Store Identity:94;AddRedisOutputCachingat ADC ConferenceProgram.cs:196; ADC ConferenceadminBypassRolesat:269, its bypass policies at:270-271,:277-284and:301,NowNextCacheat:287,ConferenceCache'sAddPolicyat:238-239and its comment at:233-237;HybridCacheServiceLocalCacheDefaultatMMCA.Common.Infrastructure/Caching/HybridCacheService.cs:69, the shorter-of rule inWriteOptionsat:403-409,RemoveAsyncremarks at:253-258,RemoveByPrefixAsyncremarks at:263-280and method at:281-300(the no-multiplexer warn-once at:283-291),GetFromSharedStoreAsyncat:216,IncrementAsyncremarks at:303-325;PublicEndpointOutputCachePolicy'sQueryKeys = "*"atMMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:101,IsCacheableRequestat:139,IsBypassedCallerat:146;AddUIShared'sIUiReadCacheregistration atMMCA.Common.UI/DependencyInjection.cs:77. The tenant vary-by stamp (2026-09-07), the eviction-consumer anchors and theMMCA.Common.OutputCachemeter 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.
- 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:120and Store Identity:109; theAddRedisCachingcalls at ADC ConferenceProgram.cs:191, Notification:117, Engagement:114, ADC Identity:137, Store Catalog:95, Sales:111and Store Identity:100;AddRedisOutputCachingat ADC ConferenceProgram.cs:202and Store Catalog:105; theNoCachebase at ADC ConferenceProgram.cs:237and Store Catalog:157; ADC ConferenceadminBypassRolesat:275, its bypass policies at:276-277,:283-290and:307,NowNextCacheat:293,ConferenceCache'sAddPolicyat:244-245and its comment at:239-243; Store Catalog's four policies atProgram.cs:158,:159,:165and:168; the output-cache pipeline step atMMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:130-132(app.UseOutputCache()at:132);HybridCacheServiceGetFromSharedStoreAsyncatMMCA.Common.Infrastructure/Caching/HybridCacheService.cs:217,RemoveAsyncremarks at:254-259,RemoveByPrefixAsyncremarks at:264-281and method at:282-301(the no-multiplexer warn-once at:284-292),IncrementAsyncat:327with remarks at:304-326, andWriteOptionsat:402-413with the shorter-of comparison at:410;ICacheService.IncrementAsyncatMMCA.Common.Application/Interfaces/ICacheService.cs:116, its<summary>at:97-104and its<remarks>at:109-115(the no-INCRsentence at:112-114). TheMMCA.Common.OutputCachemeter 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.
- Anchors re-verified against current source:
AddCachingatMMCA.Common.Infrastructure/DependencyInjection.Caching.cs:27(still called fromAddInfrastructureatDependencyInjection.cs:140), itsCacheSettingsoptions chain at:44-47,AddCommonHybridCacheat:157(theRemoveAll<ICacheService>replacement from:183), andAddCommonHybridCacheWhenRedisConfiguredat:218with its guard block at:224-227; ADC Identity's hybrid opt-in atMMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:146and itsAddRedisCachingcall at:138. Re-checked and unchanged: the other six hybrid opt-ins (ADC ConferenceProgram.cs:210, Notification:125, Engagement:122, Store Catalog:114, Sales:120, Store Identity:109), the other sixAddRedisCachingcalls (ADC Conference:191, Notification:117, Engagement:114, Store Catalog:95, Sales:111, Store Identity:100) andAddRedisOutputCachingat ADC Conference:202and Store Catalog:105. In historical revisions, left as written there: theMMCA.Common.OutputCachemeter subscription is now atMMCA.Common.Aspire/Extensions.Telemetry.cs:310, still the sixth of what are now ten chainedAddMetercalls (:305-314);RegisterOutputCacheEvictionConsumeris atMMCA.Common.Infrastructure/Messaging/Consumers/IntegrationEventConsumerExtensions.cs:158andRegisterUpcastedIntegrationEventConsumer<TEvent>at:123; the tenant vary-by stamp readsITenantContext.TenantIdatMMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:107and writes thetkey at:110; andGetRoleValuesis atMMCA.Common.Shared/Auth/ClaimsPrincipalExtensions.cs:60(Ordinal claim-type matches at:65-67),HasRoleat:76(OrdinalIgnoreCaseat: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.
DistributedCacheServiceandRedisPrefixScannerare removed.AddCachingregistersMemoryCacheServiceonly (MMCA.Common.Infrastructure/DependencyInjection.Caching.cs:78-98), and a host that registers a non-memoryIDistributedCachewithoutAddCommonHybridCachefails whenICacheServiceresolves, with anInvalidOperationExceptionnaming 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.- Prefix invalidation is a generation-token write, not a SCAN.
HybridCacheServicefolds 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 atMMCA.Common.Infrastructure/Caching/CachePrefixGenerations.cs:246), andRemoveByPrefixAsyncreplaces one token with oneStringSetAsync(CachePrefixGenerations.cs:237). Orphaned entries expire on their own TTL. The token keys sit under their ownhcg:segment (CachePrefixGenerations.cs:76) and carry no TTL: one short string per distinct invalidated prefix (:43-45). - 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,ReadFailedat:354-358,FallbackTokenat: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). - The boundary contract. A non-empty prefix must end at
:in every store, orRemoveByPrefixAsyncthrowsArgumentException(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). - 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). - Anchors re-verified against current source and re-pointed in the Decision and Trade-offs:
AddCachingDependencyInjection.Caching.cs:30, itsCacheSettingschain:47-50,AddCommonHybridCache:160(RemoveAll<ICacheService>at:186), the guarded helper:221(guard:227-230);CacheSettings.DefaultDurationCacheSettings.cs:34,LocalCacheDuration:47,PopulateLockTimeout:62;HybridCacheService.csLocalCacheDefault:65,GetFromSharedStoreAsync:246,RemoveAsyncremarks:285-291,RemoveByPrefixAsync:313-317,IncrementAsync:342(remarks:319-341),WriteOptions:427-438(comparison:435);ICacheService.IncrementAsyncICacheService.cs:133(summary:115-121, remarks:126-132);AddRedisCachingRedisCachingExtensions.cs:59(no-op:61-64, registrations:66,:67). The seven consumerProgram.csanchors were not re-checked in this pass and stand as the 2026-10-28 Revision records them. The dated revisions above that nameDistributedCacheService,RedisPrefixScanner,ScanAndDeleteAsyncor 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.
- 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.
- What was removed.
IUiReadCache,UiReadCache,UiReadCacheOptions(theUiReadCacheconfiguration section), the optionalreadCacheconstructor parameter ofEntityServiceBase,AuthUIServiceandJwtAuthenticationStateProvider,EntityServiceBase.ReadCacheandGetCachedAsync<T>(url, cancellationToken, bypassCache). - 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 threeGetCachedAsynccall sites moved to it. - 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.
- The services' Redis and hybrid wiring lives in the composed service host. No ADC or Store
service
Program.cscallsAddRedisCaching,AddRedisOutputCachingorAddCommonHybridCacheWhenRedisConfigured. All seven are built throughbuilder.AddMmcaServiceHost(ADC ConferenceProgram.cs:82, Engagement:58, Identity:82, Notification:58; Store Catalog:32, Identity:37, Sales:51), and that host callsAddRedisCaching()unconditionally (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:89) and the guarded hybrid helper (:95). The wrapper holds the onlyAddRedisDistributedCache/AddRedisClientcalls (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. - The output-cache registration and its
NoCachebase are the host's. The host registersAddOutputCacheonce withAddBasePolicy(NoCache)and then invokes the service'sConfigureOutputCachecallback (ServiceHostBuilderExtensions.cs:110-114, base at:112); ADC Conference (Program.cs:136) and Store Catalog (Program.cs:57) supply only named policies. - The Redis output-cache store is opted into by a host option. ADC Conference
(
Program.cs:129) and Store Catalog (Program.cs:53) setUseRedisOutputCaching = true(MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/MmcaServiceHostOptions.cs:55), and the host callsAddRedisOutputCaching()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). - 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). - 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 constructsPublicEndpointOutputCachePolicydirectly with a permission bypass forConferencePermissions.SessionAssetsManageas well (:186-192), through the four-argument constructor (MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/PublicEndpointOutputCachePolicy.cs:92) that noAddPublicEndpointPolicyoverload exposes.NowNextCache(:202) is the one without a bypass, andConferenceCache(:143-144) is the twelfth named policy, not the thirteenth. - 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
BestEffortwithout a layer-crossing reference. The handler does still hand-roll it, counting on its ownMMCA.Common.OutputCachemeter (MMCA.Common/Source/Presentation/MMCA.Common.API/Caching/OutputCacheEvictionHandler.cs:56,:60;OutputCacheMetrics.cs:19), but the same package already callsBestEffort.ExecuteAsyncfor the controller-sideTryEvictTagsAsynchelper (OutputCacheEvictionExtensions.cs:78,:86), on theMMCA.Common.BestEffortmeter. What keeps the handler apart is its dedicated eviction-failure counter, not a missing reference; ADR-096 records the same finding. - Anchors re-verified against current source:
AddCachingcallMMCA.Common.Infrastructure/DependencyInjection.cs:141;AddCommonHybridCacheDependencyInjection.Caching.cs:162(RemoveAll<ICacheService>:188, multiplexer resolve:193), the guarded helper:226(guard:232-235);CachePrefixGenerations.cskey builder:281;HybridCacheService.csLocalCacheDefault:71,GetFromSharedStoreAsync:266,RemoveAsyncremarks and body:305-316,RemoveByPrefixAsync:333-337(EnsureBoundary:335),IncrementAsync:362(remarks:339-361),WriteOptions:458-469(default-duration fallback:460, comparison:466);RedisCachingExtensions.csAddRedisCaching:69(no-op:71-74),AddRedisOutputCaching:103(AddStackExchangeRedisOutputCache:111);MiddlewarePipelineBuilder.cs:139-141,MiddlewarePipelineStepNames.cs:71;PublicEndpointOutputCachePolicy.csclass:47,CacheRequestAsync:106-143,IsCacheableRequest:165,IsBypassedCaller:172; ADC ConferenceadminBypassRoles:174,ConferenceCacherationale: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.
- Query caching is a host opt-in.
AddApplicationDecorators()addsCachingCommandDecoratorandCachingQueryDecoratorto the pipeline only when the host calledAddQueryCaching()first, beforeAddMmcaApplicationPipeline(...)or inside its callback; after the pipeline seals the call throws (MMCA.Common/Source/Core/MMCA.Common.Application/DependencyInjection.cs:153-156,:165,:177;AddQueryCachingat:214-221, its contract at:198-213). Without itIQueryCacheableandICacheInvalidatingare inert markers: no query result is served from or written to the cache, and a write makes noICacheServicecall. The reason is cost, not correctness: MMCA.ADC and MMCA.Store declare noIQueryCacheablequery, yet everyICacheInvalidatingcommand bumped a prefix generation and scheduled a delayed re-eviction against keys nothing populated. Neither callsAddQueryCaching(), 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:134on that branch). The cache itself is still registered separately by Infrastructure'sAddCaching, which other consumers ofICacheService(login counters, OAuth state, idempotency records) keep using either way. - The populate lock waits five seconds by default.
QueryCachePipelineSettings.DefaultPopulateLockTimeoutis five seconds (MMCA.Common/Source/Core/MMCA.Common.Application/Settings/QueryCachePipelineSettings.cs:30, the property at:43), andCacheSettings.PopulateLockTimeoutdefaults 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.
CacheOptionsis the duration alone. TheDistributedCacheEntryOptions-typed default and its factory are removed;CacheOptions.DefaultDuration(CacheOptions.cs:17) is the class's only member, and the stores apply the configuredCacheSettings.DefaultDurationto 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.