Skip to content

Feature Request: Make Redis family Configurable via Environment Variable #534

Closed

Description

@iagocavalcante

Context

Currently, the Redis configuration in the application dont able to pass family: 6 to redis

new Redis({
  host: this.redisConfig.host,
  port: this.redisConfig.port,
  options: {
    password: this.redisConfig.password,
    db: this.redisConfig.db,
    retryStrategy: createRetryStrategy(),
    family: 6,
  },
});

Proposed Solution

Introduce an environment variable to configure the family option dynamically. For example:

  • If REDIS_FAMILY is set, its value will be used (REDIS_FAMILY=6 for IPv6 or REDIS_FAMILY=4 for IPv4).
  • If REDIS_FAMILY is unset, omit the family option altogether and allow Redis to determine the default based on the network.

Implementation Example

Update the Redis initialization to include a conditional assignment for family:

new Redis({
  host: this.redisConfig.host,
  port: this.redisConfig.port,
  options: {
    password: this.redisConfig.password,
    db: this.redisConfig.db,
    retryStrategy: createRetryStrategy(),
    ...(process.env.REDIS_FAMILY ? { family: parseInt(process.env.REDIS_FAMILY, 10) } : {}),
  },
});

Acceptance Criteria

  1. The application should honor the REDIS_FAMILY environment variable, defaulting to its absence if not specified.
  2. Test cases should cover scenarios for both IPv6 (REDIS_FAMILY=6) and IPv4 (REDIS_FAMILY=4).
  3. Documentation updates to describe how to configure REDIS_FAMILY for different network environments.

Benefits

This enhancement ensures better flexibility and compatibility for various deployment setups, improving the application's configurability and portability.

Activity

  1. ju-li commented on Dec 16, 2024

    @ju-li

    This is important for deploying on services such as Railway or Fly.io which use IPV6 for internal networking.

    If you connect to Redis using their internal networking (and IPV6), data transfers are free.
    Connecting using public networking (IPV4) is possible for now but incurs data transfer fees.

  2. iagocavalcante commented on Dec 27, 2024

    @iagocavalcante
    ContributorAuthor

    This is important for deploying on services such as Railway or Fly.io which use IPV6 for internal networking.

    If you connect to Redis using their internal networking (and IPV6), data transfers are free. Connecting using public networking (IPV4) is possible for now but incurs data transfer fees.

    Yeah, I do this changes on my forked repo, i will do a propose for this issue here

  3. ju-li commented on Feb 26, 2025

    @ju-li

    This is important for deploying on services such as Railway or Fly.io which use IPV6 for internal networking.
    If you connect to Redis using their internal networking (and IPV6), data transfers are free. Connecting using public networking (IPV4) is possible for now but incurs data transfer fees.

    Yeah, I do this changes on my forked repo, i will do a propose for this issue here

    Hi @iagocavalcante Just wanted to check if you had a chance to propose for this issue. Greatly appreciate your work, man!

  4. Philipinho commented on Feb 26, 2025

    @Philipinho
    Member

    If we are to implement this, we could pass the family as param like this redis://127.0.0.1:6379?family=6, instead creating a new environment variable.

  5. ju-li commented on Feb 26, 2025

    @ju-li

    @Philipinho yeah that would be ideal too. The issue is right now params are stripped out

  6. iagocavalcante commented on Feb 26, 2025

    @iagocavalcante
    ContributorAuthor

    Sorry for the delay, I send a PR with the suggested solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions