[]
        
(Showing Draft Content)

Configure Redis Cluster using Username and Password

In Wyn Enterprise, the Redis cluster can be configured either using the ACL configuration or by configuring the username and password. In case, you have configured the Redis cluster using a password and are not able to connect to Redis, follow the below instructions,

  • For the Redis version less than 6.0, add the Password property in the connection string as shown below. The value of the Password property is set to the desired password. And,

    Server=localhost:6379,Password=xxxx,Expire=0,Db=0,ThrowOnFailure=true,Timeout=3000
  • For the Redis version higher than 6.0, add the Username property in the configuration string as shown below. The value of the Username property contains the username and password.

    Server=localhost:6379,Username=${username}:${password},Expire=0,Db=0,ThrowOnFailure=true,Timeout=3000

Note that post the Wyn Enterprise release version 7.0, configurations of the NewLife.Redis package other than Server, UserName, Password, and Db will not be supported. However, all the configurations from the StackExchange.Redis package will be supported in the Redis connection string ensuring a multi-cluster environment to work without making any changes in the connection string for users upgrading from Wyn Enterprise version v6.1.

Caution: It is recommended to use the new Redis style connection string and discard the old NewLife.Redis connection string. Redis package and strings are described below.

Redis string:

${redis0}:${port0},${redis1}:${port1},user=${username},password=${password}

NewLife string:

server=${redis0}:${port0},${redis1}:${port1};Username=${username},Password=${password}

Redis Package

To manage the Redis operations, Wyn Enterprise introduces the following two Redis driver packages,

  1. Redis.Facade: The Redis.Facade driver package outlines the interface, provides specialized exception handling, and offers extension methods to streamline and enhance Redis operations.

  2. Redis: The Redis driver package is used for the implementation of the Redis.Facade package and it incorporates essential features such as advanced connection pooling, comprehensive Redis cluster support, and the capability to fine-tune Redis key compatibility through prefix configuration.

By separating the interface and implementation packages, Wyn Enterprise ensures that the Redis.Facade package remains decoupled from third-party dependencies. The Redis.Facade package can be used as a discrete package in any application that requires Redis operations. You will not be using the Redis in any practical situation and you will be provided with the service container instead.

Redis.Facade Package

The following are the major features of the Redis.Facade package,

  • The Redis.Facade package encapsulates essential interfaces for seamless Redis read/write operations.

  • You can access the latest code within Redis.Facade.

  • Wyn Enterprise exclusively endorse list, set, and hash as complex Redis data types.

  • The pivotal interfaces within the Redis.Facade packages are IGcRedis and IGcRedisAsync.

Redis Package

The following are the major features of the Redis package,

  • The Redis package will enact the interfaces defined in Redis.Facade.

  • The Redis package will encompass the GcRedisFactory class alongside an extension method for seamless integration of the GcRedisFactory service into the DI container.

Redis Configuration

The Redis package has its own configuration PoolSize is used to configure the Redis pool. The configuration strings of PoolSize configuration are listed and described in the below table,

Configuration Item

Default Value

Description

abortConnect={bool}

True (For Azure the default value is False)

When set to true, the Connect function will refrain from establishing a connection if no servers are currently accessible.

allowAdmin={bool}

False

Activates a spectrum of commands categorized as potentially risky.

channelPrefix={string}

Null

An optional prefix for all pub/sub operations on channels.

checkCertificateRevocation={bool}

True

A boolean value indicating whether authentication includes checking the certificate revocation list.

connectRetry={int}

3

The count of initial Connect retries to perform.

connectTimeout={int}

5000

Timeout duration (in milliseconds) for connect operations.

configChannel={string}

_Booksleeve_MasterChanged

The designated channel name for broadcasting configuration alterations.

configCheckSeconds={int}

60

Interval (in seconds) for configuration checks, acting as a keep-alive mechanism for interactive sockets, where supported.

defaultDatabase={int}

Null

The default database index, ranging from 0 to the total number of databases minus 1.

keepAlive={int}

-1

Interval (in seconds) for sending a message to maintain socket vitality (default is 60 seconds).

name={string}

Null

An identifier for the connection within Redis.

password={string}

Null

The authentication password for the Redis server.

user={string}

Null

The designated user for the Redis server, specifically for utilization with Access Control Lists (ACLs) on Redis 6 and above.

resolveDns={bool}

False

Indicates a preference for explicit and prompt DNS resolution, as opposed to implicit resolution.

serviceName={string}

Null

Used to establish a connection to a primary service managed by Sentinel.

ssl={bool}

False

Indicates the utilization of SSL encryption.

sslHost={string}

Null

Mandates a specific SSL host identity on the server's certificate.

sslProtocols={enum}

Null

Supported SSL/TLS versions for encrypted connections, separated by | for multiple values.

syncTimeout={int}

5000

Duration (in milliseconds) permitted for synchronous operations to complete.

asyncTimeout={int}

SyncTimeout

Time allowance (in milliseconds) for asynchronous operations to conclude.

tiebreaker={string}

_Booksleeve_TieBreak

Designated key employed to resolve server selection in a potentially uncertain primary scenario.

PoolSize

null | number (4<PoolSize<200)

Specifies the utilization of RedisConnectionPool and establishes the pool size for RedisConnectionPool.