RedisCacheOptions
Redis cache options
/// <summary>
/// Redis cache options
/// </summary>
public class RedisCacheOptions
{
/// <summary>
/// Gets or sets whether connect/configuration timeouts should be explicitly notified via a TimeoutException.
/// Default value is true
/// </summary>
public bool AbortOnConnectFail { get; set; }
/// <summary>
/// Indicates whether admin operations should be allowed.
/// Default value is false
/// </summary>
public bool AllowAdmin { get; set; }
/// <summary>
/// Specifies the time in milliseconds that the system should allow for asynchronous operations (defaults to SyncTimeout).
/// </summary>
public int AsyncTimeout { get; set; }
/// <summary>
/// Gets or sets whether the library should identify itself by library-name/version when possible.
/// Default value is true
/// </summary>
public bool SetClientLibrary { get; set; }
/// <summary>
/// Gets or sets the library name to use for CLIENT SETINFO lib-name calls to Redis during handshake.
/// Defaults value is "SE.Redis".
/// </summary>
/// <remarks>If the value is null, empty or whitespace, then the value from the options-provideer is used;
/// to disable the library name feature, use <see cref="SetClientLibrary"/> instead.</remarks>
public string? LibraryName { get; set; }
/// <summary>
/// Automatically encodes and decodes channels.
/// </summary>
public RedisChannel ChannelPrefix { get; set; }
/// <summary>
/// The client name to use for all connections.
/// </summary>
public string? ClientName { get; set; }
/// <summary>
/// Channel to use for broadcasting and listening for configuration change notification.
/// Default value is "__Booksleeve_MasterChanged"
/// </summary>
public string? ConfigurationChannel { get; set; }
/// <summary>
/// Check configuration every n seconds (every minute by default).
/// </summary>
public int ConfigCheckSeconds { get; set; }
/// <summary>
/// Specifies the time in milliseconds that should be allowed for connection (defaults to 5 seconds unless SyncTimeout is higher).
/// </summary>
public int ConnectTimeoutInMilliseconds { get; set; }
/// <summary>
/// Specifies the default database to be used when calling <see cref="ConnectionMultiplexer.GetDatabase(int, object)"/> without any parameters.
/// </summary>
public int? DefaultDatabase { get; set; }
/// <summary>
/// Specifies the time in seconds at which connections should be pinged to ensure validity.
/// -1 Defaults to 60 Seconds
/// </summary>
public int KeepAliveInSeconds { get; set; }
/// <summary>
/// The username to use to authenticate with the server.
/// </summary>
public string? UserName { get; set; }
/// <summary>
/// The password to use to authenticate with the server.
/// </summary>
public string? Password { get; set; }
/// <summary>
/// Type of proxy to use (if any); for example <see cref="StackExchange.Redis.Proxy"/>.
/// Default value is Proxy.None
/// </summary>
public Proxy Proxy { get; set; }
/// <summary>
/// The backlog policy to be used for commands when a connection is unhealthy.
/// </summary>
public BacklogPolicy? BacklogPolicy { get; set; }
/// <summary>
/// Indicates whether endpoints should be resolved via DNS before connecting.
/// If enabled the ConnectionMultiplexer will not re-resolve DNS when attempting to re-connect after a connection failure.
/// Default value is false
/// </summary>
public bool ResolveDns { get; set; }
/// <summary>
/// The service name used to resolve a service via sentinel.
/// </summary>
public string? ServiceName { get; set; }
/// <summary>
/// Indicates whether the connection should be encrypted.
/// </summary>
public bool Ssl { get; set; }
/// <summary>
/// Gets or sets the SocketManager instance to be used with these options.
/// If this is null a shared cross-multiplexer <see cref="SocketManager"/> is used.
/// </summary>
/// <remarks>
/// This is only used when a <see cref="ConnectionMultiplexer"/> is created.
/// Modifying it afterwards will have no effect on already-created multiplexers.
/// </remarks>
public SocketManager? SocketManager { get; set; }
/// <summary>
/// A <see cref="SslClientAuthenticationOptions"/> provider for a given host, for custom TLS connection options.
/// Note: this overrides *all* other TLS and certificate settings, only for advanced use cases.
/// </summary>
public Func<string, SslClientAuthenticationOptions>? SslClientAuthenticationOptions { get; set; }
/// <summary>
/// The target-host to use when validating SSL certificate; setting a value here enables SSL mode.
/// </summary>
public string? SslHost { get; set; }
/// <summary>
/// Configures which SSL/TLS protocols should be allowed. If not set, defaults are chosen by the .NET framework.
/// </summary>
public SslProtocols SslProtocols { get; set; }
/// <summary>
/// Specifies the time in milliseconds that the system should allow for synchronous operations (defaults to 5 seconds).
/// </summary>
public int SyncTimeoutInSeconds { get; set; }
/// <summary>
/// Tie-breaker used to choose between primaries (must match the endpoint exactly).
/// </summary>
public string? TieBreaker { get; set; }
/// <summary>
/// The server version to assume.
/// Default version is RedisFeatures.v3_0_0 <see cref="RedisFeatures"/>
/// </summary>
public Version? Version { get; set; }
/// <summary>
/// A Boolean value that specifies whether the certificate revocation list is checked during authentication.
/// </summary>
public bool CheckCertificateRevocation { get; set; }
/// <summary>
/// Redis host:port endpoints
/// </summary>
public string[]? Hosts { get; set; }
/// <summary>
/// Controls how often the connection heartbeats. A heartbeat includes:
/// - Evaluating if any messages have timed out
/// - Evaluating connection status (checking for failures)
/// - Sending a server message to keep the connection alive if needed
/// </summary>
/// <remarks>
/// This defaults to 1000 milliseconds and should not be changed for most use cases.
/// If for example you want to evaluate whether commands have violated the <see cref="RedisCacheOptions.AsyncTimeout"/> at a lower fidelity
/// than 1000 milliseconds, you could lower this value.
/// Be aware setting this very low incurs additional overhead of evaluating the above more often.
/// </remarks>
public TimeSpan HeartbeatInterval { get; set; }
/// <summary>
/// Reconnect retry policy
/// </summary>
public IReconnectRetryPolicy? ReconnectRetryPolicy { get; set; }
/// <summary>
/// Should exceptions include identifiable details? (key names, additional .Data annotations)
/// Default value is true
/// </summary>
public bool IncludeDetailInExceptions { get; set; }
/// <summary>
/// Should exceptions include performance counter details?
/// </summary>
/// <remarks>
/// CPU usage, etc - note that this can be problematic on some platforms.
/// Default value is false
/// </remarks>
public bool IncludePerformanceCountersInExceptions { get; set; }
/// <summary>
/// The number of times to repeat the initial connect cycle if no servers respond promptly.
/// Default value is 3
/// </summary>
public int ConnectRetry { get; set; }
/// <summary>
/// Allows custom transport implementations, such as http-tunneling via a proxy.
/// </summary>
public Tunnel? Tunnel { get; set; }
/// <summary>
/// Allows modification of a <see cref="Socket"/> between creation and connection.
/// Passed in is the endpoint we're connecting to, which type of connection it is, and the socket itself.
/// For example, a specific local IP endpoint could be bound, linger time altered, etc.
/// </summary>
public Action<EndPoint, ConnectionType, Socket>? BeforeSocketConnect { get; set; }
/// <summary>
/// A LocalCertificateSelectionCallback delegate responsible for selecting the certificate used for authentication; note
/// that this cannot be specified in the configuration-string.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1009:DeclareEventHandlersCorrectly")]
public event LocalCertificateSelectionCallback? CertificateSelection;
/// <summary>
/// A RemoteCertificateValidationCallback delegate responsible for validating the certificate supplied by the remote party; note
/// that this cannot be specified in the configuration-string.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1009:DeclareEventHandlersCorrectly")]
public event RemoteCertificateValidationCallback? CertificateValidation;
}
Last updated