#### [Abblix\.Jwt](https://www.abblix.com/docs/api/abblix-jwt 'index')
### [Abblix\.Jwt](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt 'Abblix\.Jwt')

## ReplayCacheServiceCollectionExtensions Class

Wires the replay cache that remembers the identifiers of single\-use tokens already accepted\.

```csharp
public static class ReplayCacheServiceCollectionExtensions
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → ReplayCacheServiceCollectionExtensions
### Methods

## ReplayCacheServiceCollectionExtensions\.AddDistributedReplayCache\(this IServiceCollection\) Method {#Abblix.Jwt.ReplayCacheServiceCollectionExtensions.AddDistributedReplayCache(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection)}

Registers the replay cache over the host's `IDistributedCache`, or over an in\-process one when the host
registers none, as the [IReplayCache](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.ReplayPrevention.IReplayCache 'Abblix\.Jwt\.ReplayPrevention\.IReplayCache')\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddDistributedReplayCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
```
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.Jwt.ReplayCacheServiceCollectionExtensions.AddDistributedReplayCache(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).services}

The service collection\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')

### Remarks

The registration of the store made by every receiver of Security Event Tokens or logout tokens, so a host
running several of them shares one store under one prefix. The OpenID Connect server in the same host puts
its store over the host's entity storage in place of this one, whichever of them registers first, and the
receivers reserve there. TryAdd, so a store the host registered before wins.

A package with a policy of its own decorates the registered store rather than registering another, so every
package in the host keeps reserving in one store. Beside the OpenID Connect server, a decoration made before
the server registers is kept as the host's own store, and the server reserves in it too.

The cache itself is the host's choice. Without one the reservations are kept in this process, which is enough for
a single instance; several instances need a shared cache, Redis or another backend, or a token refused by one
is accepted by the next.
