# RedisResource Methods

- Package: [Aspire.Hosting.Redis](/reference/api/csharp/aspire.hosting.redis.md)
- Type: [RedisResource](/reference/api/csharp/aspire.hosting.redis/redisresource.md)
- Kind: `Methods`
- Members: `1`

A resource that represents a Redis resource independent of the hosting model.

## GetConnectionStringAsync(CancellationToken)

- Name: `GetConnectionStringAsync(CancellationToken)`
- Returns: `ValueTask<string?>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Redis/RedisResource.cs#L124-L129)

Gets the connection string for the Redis server.

```csharp
public class RedisResource
{
    public ValueTask<string?> GetConnectionStringAsync(
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `cancellationToken` (`CancellationToken`) `optional`
  A `Threading.CancellationToken` to observe while waiting for the task to complete.

## Returns

`ValueTask<string?>` -- A connection string for the redis server in the form "host:port".
