#### [Abblix\.Oidc\.Server](https://www.abblix.com/en/docs/api/abblix-oidc-server 'index')
### [Abblix\.Oidc\.Server\.Features\.Storages](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages 'Abblix\.Oidc\.Server\.Features\.Storages')

## IEntityStorage Interface

Key/value storage abstraction over short\-lived OIDC entities \(authorization codes, PAR
requests, CIBA/device authorization records, JWT statuses, rate\-limit counters\)\. Each entry
has an expiration policy expressed via [StorageOptions](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.StorageOptions 'Abblix\.Oidc\.Server\.Features\.Storages\.StorageOptions'); implementations may be
in\-process or distributed\.

```csharp
public interface IEntityStorage
```

Derived  
↳ [DistributedCacheStorage](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.DistributedCacheStorage 'Abblix\.Oidc\.Server\.Features\.Storages\.DistributedCacheStorage')

### Remarks
Implementations must support atomic get\-and\-remove semantics when
`removeOnRetrieval` is true so that single\-use credentials \(authorization codes, PAR
request URIs\) cannot be replayed across concurrent token requests\.
### Methods

## IEntityStorage\.GetAsync\<T\>\(string, bool, Nullable\<CancellationToken\>\) Method {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.GetAsync_T_(string,bool,System.Nullable_System.Threading.CancellationToken_)}

Retrieves the entity stored under [key](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.IEntityStorage#Abblix.Oidc.Server.Features.Storages.IEntityStorage.GetAsync_T_(string,bool,System.Nullable_System.Threading.CancellationToken_).key 'Abblix\.Oidc\.Server\.Features\.Storages\.IEntityStorage\.GetAsync\<T\>\(string, bool, System\.Nullable\<System\.Threading\.CancellationToken\>\)\.key'), optionally deleting it
atomically as part of the same operation to enforce single\-use semantics\.

```csharp
System.Threading.Tasks.Task<T?> GetAsync<T>(string key, bool removeOnRetrieval, System.Nullable<System.Threading.CancellationToken> token=null);
```
#### Type parameters

###### `T` {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.GetAsync_T_(string,bool,System.Nullable_System.Threading.CancellationToken_).T}

The type of the entity to retrieve\.
#### Parameters

###### `key` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.GetAsync_T_(string,bool,System.Nullable_System.Threading.CancellationToken_).key}

The key associated with the entity\.

###### `removeOnRetrieval` [System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean') {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.GetAsync_T_(string,bool,System.Nullable_System.Threading.CancellationToken_).removeOnRetrieval}

When true, the entry must be removed atomically with the
            read so that a concurrent caller cannot observe the same value\.

###### `token` [System\.Nullable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1') {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.GetAsync_T_(string,bool,System.Nullable_System.Threading.CancellationToken_).token}

An optional cancellation token\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[T](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.IEntityStorage#Abblix.Oidc.Server.Features.Storages.IEntityStorage.GetAsync_T_(string,bool,System.Nullable_System.Threading.CancellationToken_).T 'Abblix\.Oidc\.Server\.Features\.Storages\.IEntityStorage\.GetAsync\<T\>\(string, bool, System\.Nullable\<System\.Threading\.CancellationToken\>\)\.T')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
The stored entity, or `null` when no entry is present or it has expired\.

## IEntityStorage\.RemoveAsync\(string, Nullable\<CancellationToken\>\) Method {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.RemoveAsync(string,System.Nullable_System.Threading.CancellationToken_)}

Removes the entity stored under [key](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.IEntityStorage#Abblix.Oidc.Server.Features.Storages.IEntityStorage.RemoveAsync(string,System.Nullable_System.Threading.CancellationToken_).key 'Abblix\.Oidc\.Server\.Features\.Storages\.IEntityStorage\.RemoveAsync\(string, System\.Nullable\<System\.Threading\.CancellationToken\>\)\.key'); succeeds silently when no entry
is present\.

```csharp
System.Threading.Tasks.Task RemoveAsync(string key, System.Nullable<System.Threading.CancellationToken> token=null);
```
#### Parameters

###### `key` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.RemoveAsync(string,System.Nullable_System.Threading.CancellationToken_).key}

The key of the entity to remove\.

###### `token` [System\.Nullable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1') {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.RemoveAsync(string,System.Nullable_System.Threading.CancellationToken_).token}

An optional cancellation token\.

#### Returns
[System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task')  
A task that completes once the removal request has been processed\.

## IEntityStorage\.SetAsync\<T\>\(string, T, StorageOptions, Nullable\<CancellationToken\>\) Method {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.SetAsync_T_(string,T,Abblix.Oidc.Server.Features.Storages.StorageOptions,System.Nullable_System.Threading.CancellationToken_)}

Stores an entity under [key](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.IEntityStorage#Abblix.Oidc.Server.Features.Storages.IEntityStorage.SetAsync_T_(string,T,Abblix.Oidc.Server.Features.Storages.StorageOptions,System.Nullable_System.Threading.CancellationToken_).key 'Abblix\.Oidc\.Server\.Features\.Storages\.IEntityStorage\.SetAsync\<T\>\(string, T, Abblix\.Oidc\.Server\.Features\.Storages\.StorageOptions, System\.Nullable\<System\.Threading\.CancellationToken\>\)\.key'), replacing any existing value, with the
expiration behavior described by [options](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.IEntityStorage#Abblix.Oidc.Server.Features.Storages.IEntityStorage.SetAsync_T_(string,T,Abblix.Oidc.Server.Features.Storages.StorageOptions,System.Nullable_System.Threading.CancellationToken_).options 'Abblix\.Oidc\.Server\.Features\.Storages\.IEntityStorage\.SetAsync\<T\>\(string, T, Abblix\.Oidc\.Server\.Features\.Storages\.StorageOptions, System\.Nullable\<System\.Threading\.CancellationToken\>\)\.options')\.

```csharp
System.Threading.Tasks.Task SetAsync<T>(string key, T value, Abblix.Oidc.Server.Features.Storages.StorageOptions options, System.Nullable<System.Threading.CancellationToken> token=null);
```
#### Type parameters

###### `T` {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.SetAsync_T_(string,T,Abblix.Oidc.Server.Features.Storages.StorageOptions,System.Nullable_System.Threading.CancellationToken_).T}

The type of the entity to store\.
#### Parameters

###### `key` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.SetAsync_T_(string,T,Abblix.Oidc.Server.Features.Storages.StorageOptions,System.Nullable_System.Threading.CancellationToken_).key}

The unique key used to store and later retrieve the value\.

###### `value` [T](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.IEntityStorage#Abblix.Oidc.Server.Features.Storages.IEntityStorage.SetAsync_T_(string,T,Abblix.Oidc.Server.Features.Storages.StorageOptions,System.Nullable_System.Threading.CancellationToken_).T 'Abblix\.Oidc\.Server\.Features\.Storages\.IEntityStorage\.SetAsync\<T\>\(string, T, Abblix\.Oidc\.Server\.Features\.Storages\.StorageOptions, System\.Nullable\<System\.Threading\.CancellationToken\>\)\.T') {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.SetAsync_T_(string,T,Abblix.Oidc.Server.Features.Storages.StorageOptions,System.Nullable_System.Threading.CancellationToken_).value}

The entity to store\.

###### `options` [StorageOptions](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.StorageOptions 'Abblix\.Oidc\.Server\.Features\.Storages\.StorageOptions') {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.SetAsync_T_(string,T,Abblix.Oidc.Server.Features.Storages.StorageOptions,System.Nullable_System.Threading.CancellationToken_).options}

Expiration policy for the stored entry\.

###### `token` [System\.Nullable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1') {#Abblix.Oidc.Server.Features.Storages.IEntityStorage.SetAsync_T_(string,T,Abblix.Oidc.Server.Features.Storages.StorageOptions,System.Nullable_System.Threading.CancellationToken_).token}

An optional cancellation token\.

#### Returns
[System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task')  
A task that completes once the entity has been written\.
