RedisBuilderExtensions Methods
Class Methods 13 members
Provides extension methods for adding Redis resources to the application model.
AddRedis(IDistributedApplicationBuilder, string, int?) Section titled AddRedis(IDistributedApplicationBuilder, string, int?) extension IResourceBuilder<RedisResource> Adds a Redis container to the application model.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisResource> AddRedis( this IDistributedApplicationBuilder builder, string name, int? port) { // ... }}Parameters
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder. name string The name of the resource. This name will be used as the connection string name when referenced in a dependency. port int? The host port to bind the underlying container to. Returns
IResourceBuilder<RedisResource> A reference to the ApplicationModel.IResourceBuilder`1. Remarks
This resource includes built-in health checks. When this resource is referenced as a dependency using the ResourceBuilderExtensions.WaitFor extension method then the dependent resource will wait until the Redis resource is able to service requests.
AddRedis(IDistributedApplicationBuilder, string, int?, IResourceBuilder<ParameterResource>) Section titled AddRedis(IDistributedApplicationBuilder, string, int?, IResourceBuilder<ParameterResource>) extension IResourceBuilder<RedisResource> Adds a Redis container to the application model.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisResource> AddRedis( this IDistributedApplicationBuilder builder, string name, int? port = null, IResourceBuilder<ParameterResource>? password = null) { // ... }}Parameters
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder. name string The name of the resource. This name will be used as the connection string name when referenced in a dependency. port int? optional The host port to bind the underlying container to. password IResourceBuilder<ParameterResource> optional The parameter used to provide the password for the Redis resource. If null a random password will be generated. Returns
IResourceBuilder<RedisResource> A reference to the ApplicationModel.IResourceBuilder`1. Remarks
This resource includes built-in health checks. When this resource is referenced as a dependency using the ResourceBuilderExtensions.WaitFor extension method then the dependent resource will wait until the Redis resource is able to service requests.
WithDataBindMount(IResourceBuilder<RedisResource>, string, bool) Section titled WithDataBindMount(IResourceBuilder<RedisResource>, string, bool) extension IResourceBuilder<RedisResource> Adds a bind mount for the data folder to a Redis container resource and enables Redis persistence.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisResource> WithDataBindMount( this IResourceBuilder<RedisResource> builder, string source, bool isReadOnly = false) { // ... }}Parameters
builder IResourceBuilder<RedisResource> The resource builder. source string The source directory on the host to mount into the container. isReadOnly bool optional A flag that indicates if this is a read-only mount. Setting this to true will disable Redis persistence. Defaults to false. Returns
IResourceBuilder<RedisResource> The ApplicationModel.IResourceBuilder`1. Remarks
Use
RedisBuilderExtensions.WithPersistence to adjust Redis persistence configuration, e.g.: var cache = builder.AddRedis("cache") .WithDataBindMount("myredisdata") .WithPersistence(TimeSpan.FromSeconds(10), 5);WithDataBindMount(IResourceBuilder<RedisInsightResource>, string) Section titled WithDataBindMount(IResourceBuilder<RedisInsightResource>, string) extension IResourceBuilder<RedisInsightResource> Adds a bind mount for the data folder to a Redis Insight container resource.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisInsightResource> WithDataBindMount( this IResourceBuilder<RedisInsightResource> builder, string source) { // ... }}Parameters
builder IResourceBuilder<RedisInsightResource> The resource builder. source string The source directory on the host to mount into the container. Returns
IResourceBuilder<RedisInsightResource> The ApplicationModel.IResourceBuilder`1. WithDataVolume(IResourceBuilder<RedisResource>, string?, bool) Section titled WithDataVolume(IResourceBuilder<RedisResource>, string?, bool) extension IResourceBuilder<RedisResource> Adds a named volume for the data folder to a Redis container resource and enables Redis persistence.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisResource> WithDataVolume( this IResourceBuilder<RedisResource> builder, string? name = null, bool isReadOnly = false) { // ... }}Parameters
builder IResourceBuilder<RedisResource> The resource builder. name string? optional The name of the volume. Defaults to an auto-generated name based on the application and resource names. isReadOnly bool optional A flag that indicates if this is a read-only volume. Setting this to true will disable Redis persistence. Defaults to false. Returns
IResourceBuilder<RedisResource> The ApplicationModel.IResourceBuilder`1. Remarks
Use
RedisBuilderExtensions.WithPersistence to adjust Redis persistence configuration, e.g.: var cache = builder.AddRedis("cache") .WithDataVolume() .WithPersistence(TimeSpan.FromSeconds(10), 5);WithDataVolume(IResourceBuilder<RedisInsightResource>, string?) Section titled WithDataVolume(IResourceBuilder<RedisInsightResource>, string?) extension IResourceBuilder<RedisInsightResource> Adds a named volume for the data folder to a Redis Insight container resource.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisInsightResource> WithDataVolume( this IResourceBuilder<RedisInsightResource> builder, string? name = null) { // ... }}Parameters
builder IResourceBuilder<RedisInsightResource> The resource builder. name string? optional The name of the volume. Defaults to an auto-generated name based on the application and resource names. Returns
IResourceBuilder<RedisInsightResource> The ApplicationModel.IResourceBuilder`1. WithHostPort(IResourceBuilder<RedisCommanderResource>, int?) Section titled WithHostPort(IResourceBuilder<RedisCommanderResource>, int?) extension IResourceBuilder<RedisCommanderResource> Configures the host port that the Redis Commander resource is exposed on instead of using randomly assigned port.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisCommanderResource> WithHostPort( this IResourceBuilder<RedisCommanderResource> builder, int? port) { // ... }}Parameters
builder IResourceBuilder<RedisCommanderResource> The resource builder for Redis Commander. port int? The port to bind on the host. If null is used random port will be assigned. Returns
IResourceBuilder<RedisCommanderResource> The resource builder for RedisCommander. WithHostPort(IResourceBuilder<RedisInsightResource>, int?) Section titled WithHostPort(IResourceBuilder<RedisInsightResource>, int?) extension IResourceBuilder<RedisInsightResource> Configures the host port that the Redis Insight resource is exposed on instead of using randomly assigned port.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisInsightResource> WithHostPort( this IResourceBuilder<RedisInsightResource> builder, int? port) { // ... }}Parameters
builder IResourceBuilder<RedisInsightResource> The resource builder for Redis Insight. port int? The port to bind on the host. If null is used random port will be assigned. Returns
IResourceBuilder<RedisInsightResource> The resource builder for RedisInsight. WithHostPort(IResourceBuilder<RedisResource>, int?) Section titled WithHostPort(IResourceBuilder<RedisResource>, int?) extension IResourceBuilder<RedisResource> Configures the host port that the Redis resource is exposed on instead of using randomly assigned port.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisResource> WithHostPort( this IResourceBuilder<RedisResource> builder, int? port) { // ... }}Parameters
builder IResourceBuilder<RedisResource> The resource builder. port int? The port to bind on the host. If null is used random port will be assigned. Returns
IResourceBuilder<RedisResource> The ApplicationModel.IResourceBuilder`1. WithPassword(IResourceBuilder<RedisResource>, IResourceBuilder<ParameterResource>) Section titled WithPassword(IResourceBuilder<RedisResource>, IResourceBuilder<ParameterResource>) extension IResourceBuilder<RedisResource> Configures the password that the Redis resource is used.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisResource> WithPassword( this IResourceBuilder<RedisResource> builder, IResourceBuilder<ParameterResource>? password) { // ... }}Parameters
builder IResourceBuilder<RedisResource> The resource builder. password IResourceBuilder<ParameterResource> The parameter used to provide the password for the Redis resource. If null, no password will be configured. Returns
IResourceBuilder<RedisResource> The ApplicationModel.IResourceBuilder`1. WithPersistence(IResourceBuilder<RedisResource>, TimeSpan?, long) Section titled WithPersistence(IResourceBuilder<RedisResource>, TimeSpan?, long) extension IResourceBuilder<RedisResource> Configures a Redis container resource for persistence.
public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisResource> WithPersistence( this IResourceBuilder<RedisResource> builder, TimeSpan? interval = null, long keysChangedThreshold = 1) { // ... }}Parameters
builder IResourceBuilder<RedisResource> The resource builder. interval TimeSpan? optional The interval between snapshot exports. Defaults to 60 seconds. keysChangedThreshold long optional The number of key change operations required to trigger a snapshot at the interval. Defaults to 1. Returns
IResourceBuilder<RedisResource> The ApplicationModel.IResourceBuilder`1. Remarks
Use with
RedisBuilderExtensions.WithDataBindMount or RedisBuilderExtensions.WithDataVolume to persist Redis data across sessions with custom persistence configuration, e.g.: var cache = builder.AddRedis("cache") .WithDataVolume() .WithPersistence(TimeSpan.FromSeconds(10), 5);WithRedisCommander(IResourceBuilder<RedisResource>, Action<IResourceBuilder<RedisCommanderResource>>, string?) Section titled WithRedisCommander(IResourceBuilder<RedisResource>, Action<IResourceBuilder<RedisCommanderResource>>, string?) extension IResourceBuilder<RedisResource> Configures a container resource for Redis Commander which is pre-configured to connect to the
RedisResource that this method is used on. public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisResource> WithRedisCommander( this IResourceBuilder<RedisResource> builder, Action<IResourceBuilder<RedisCommanderResource>>? configureContainer = null, string? containerName = null) { // ... }}Parameters
builder IResourceBuilder<RedisResource> The ApplicationModel.IResourceBuilder`1 for the RedisResource. configureContainer Action<IResourceBuilder<RedisCommanderResource>> optional Configuration callback for Redis Commander container resource. containerName string? optional Override the container name used for Redis Commander. Remarks
This version of the package defaults to the tag of the container image.
WithRedisInsight(IResourceBuilder<RedisResource>, Action<IResourceBuilder<RedisInsightResource>>, string?) Section titled WithRedisInsight(IResourceBuilder<RedisResource>, Action<IResourceBuilder<RedisInsightResource>>, string?) extension IResourceBuilder<RedisResource> Configures a container resource for Redis Insight which is pre-configured to connect to the
RedisResource that this method is used on. public static class RedisBuilderExtensions{ public static IResourceBuilder<RedisResource> WithRedisInsight( this IResourceBuilder<RedisResource> builder, Action<IResourceBuilder<RedisInsightResource>>? configureContainer = null, string? containerName = null) { // ... }}Parameters
builder IResourceBuilder<RedisResource> The ApplicationModel.IResourceBuilder`1 for the RedisResource. configureContainer Action<IResourceBuilder<RedisInsightResource>> optional Configuration callback for Redis Insight container resource. containerName string? optional Override the container name used for Redis Insight. Remarks
This version of the package defaults to the tag of the container image.