Skip to content

Backends

Four backends implement the same IActionCache contract. Register one, or several — see Layered backends.

MemoryRedisSQL ServerAzure Cosmos DB
PackageActionCacheActionCache.RedisActionCache.SqlServerActionCache.AzureCosmos
Shared across instancesNoYesYesYes
LockingSemaphoreSlimnone neededsp_getapplocknone needed
Distributed single flightYesYes
Cancellationchecked before dispatchchecked before dispatchforwardedforwarded

Why locking differs

Each backend extends ActionCacheBase<TLock>, which carries a locking strategy chosen for what that store can already do atomically.

Redis and Cosmos need none: their operations are atomic as issued — Redis through Lua scripts, Cosmos through single-document writes. SQL Server uses sp_getapplock. The memory backend needs a SemaphoreSlim because the namespace key index is a read-modify-write that IMemoryCache does not make atomic; its locker is a singleton, since caches are created per request and a per-instance locker would guard nothing.