> ## Documentation Index
> Fetch the complete documentation index at: https://ai.easyaf.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# RedisMcpTaskStore

> An [IMcpTaskStorePlus](/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskStorePlus) that persists snapshots as Redis strings with `PEXPIREAT` from ...

## Definition

**Assembly:** CloudNimble.McpEssentials.Redis.dll

**Namespace:** CloudNimble.McpEssentials.Redis.Tasks

**Inheritance:** CloudNimble.McpEssentials.Core.Tasks.McpTaskStoreBase

## Syntax

```csharp theme={"dark"}
CloudNimble.McpEssentials.Redis.Tasks.RedisMcpTaskStore
```

## Summary

An [IMcpTaskStorePlus](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/IMcpTaskStorePlus.md) that persists snapshots as Redis strings with
`PEXPIREAT` from [StoredMcpTask.DiscardAfter](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/StoredMcpTask.md#discardafter) and fans resolved input
over pub/sub.

## Remarks

Register as a singleton. The host owns `IConnectionMultiplexer`.
Native expiry is the drain; [McpTaskStoreBase.AutoSweep](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Core/Tasks/McpTaskStoreBase.md#autosweep) defaults to
[`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). `WAIT` after create is off until
[RedisMcpTaskStore.WaitReplicas](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Redis/Tasks/RedisMcpTaskStore.md#waitreplicas) is positive. Eventually-consistent Redis without wait
is not SEP-2663 durable across nodes.

## Constructors

### &#x20;.ctor

Initializes a new instance of the [RedisMcpTaskStore](https://ai.easyaf.dev/mcpessentials/api-reference/CloudNimble/McpEssentials/Redis/Tasks/RedisMcpTaskStore.md) class.

#### Syntax

```csharp theme={"dark"}
public RedisMcpTaskStore(StackExchange.Redis.IConnectionMultiplexer multiplexer, System.Func<string> getCurrentUserId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `multiplexer` | `StackExchange.Redis.IConnectionMultiplexer` | The Redis connection. The host owns its lifetime. |
| `getCurrentUserId` | `System.Func<string?>` | Returns the current user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when unauthenticated. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *multiplexer* or *getCurrentUserId* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor

Initializes a new instance that always uses *userId*.

#### Syntax

```csharp theme={"dark"}
public RedisMcpTaskStore(StackExchange.Redis.IConnectionMultiplexer multiplexer, string userId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `multiplexer` | `StackExchange.Redis.IConnectionMultiplexer` | The Redis connection. The host owns its lifetime. |
| `userId` | `string?` | The user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to treat the process as unauthenticated. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *multiplexer* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor

Initializes a new instance that resolves the user from a [ClaimsPrincipal](https://learn.microsoft.com/dotnet/api/system.security.claims.claimsprincipal).

#### Syntax

```csharp theme={"dark"}
public RedisMcpTaskStore(StackExchange.Redis.IConnectionMultiplexer multiplexer, System.Func<System.Security.Claims.ClaimsPrincipal> getPrincipal)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `multiplexer` | `StackExchange.Redis.IConnectionMultiplexer` | The Redis connection. The host owns its lifetime. |
| `getPrincipal` | `System.Func<System.Security.Claims.ClaimsPrincipal?>` | Returns the principal for the current request. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *multiplexer* or *getPrincipal* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor

Initializes a new instance with deferred factories so the MCP server builder can
capture the store before `Build()`.

#### Syntax

```csharp theme={"dark"}
public RedisMcpTaskStore(System.Func<StackExchange.Redis.IConnectionMultiplexer> getMultiplexer, System.Func<string> getCurrentUserId)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `getMultiplexer` | `System.Func<StackExchange.Redis.IConnectionMultiplexer>` | Returns the multiplexer from the built provider. |
| `getCurrentUserId` | `System.Func<string?>` | Returns the current user identifier, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when unauthenticated. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *getMultiplexer* or *getCurrentUserId* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

## Properties

### &#x20;Database Virtual

Gets or sets the Redis database index, or `-1` for the multiplexer default.

#### Syntax

```csharp theme={"dark"}
public virtual int Database { get; set; }
```

#### Property Value

Type: `int`

### &#x20;KeyPrefix Virtual

Gets or sets the key prefix. Task keys are `{prefix}:task:{taskId}`.

#### Syntax

```csharp theme={"dark"}
public virtual string KeyPrefix { get; set; }
```

#### Property Value

Type: `string`

### &#x20;WaitReplicas Virtual

Gets or sets how many replicas must acknowledge a create. Zero skips `WAIT`.

#### Syntax

```csharp theme={"dark"}
public virtual int WaitReplicas { get; set; }
```

#### Property Value

Type: `int`

### &#x20;WaitTimeout Virtual

Gets or sets how long to wait for replica acknowledgement.

#### Syntax

```csharp theme={"dark"}
public virtual System.TimeSpan WaitTimeout { get; set; }
```

#### Property Value

Type: `System.TimeSpan`

## Methods

### &#x20;Dispose Virtual

#### Syntax

```csharp theme={"dark"}
public virtual void Dispose()
```

## Related APIs

* System.IDisposable


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.