Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/ServiceStack.Redis/PooledRedisClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public partial class PooledRedisClientManager
public int? ConnectTimeout { get; set; }
public int? SocketSendTimeout { get; set; }
public int? SocketReceiveTimeout { get; set; }
public int? IdleTimeOutSecs { get; set; }

/// <summary>
/// Gets or sets object key prefix.
Expand Down Expand Up @@ -233,6 +234,10 @@ public IRedisClient GetClient()
{
inActiveClient.ReceiveTimeout = this.SocketReceiveTimeout.Value;
}
if (this.IdleTimeOutSecs.HasValue)
{
inActiveClient.IdleTimeOutSecs = this.IdleTimeOutSecs.Value;
}

inActiveClient.NamespacePrefix = NamespacePrefix;

Expand Down Expand Up @@ -325,6 +330,10 @@ public virtual IRedisClient GetReadOnlyClient()
{
inActiveClient.ReceiveTimeout = this.SocketReceiveTimeout.Value;
}
if (this.IdleTimeOutSecs.HasValue)
{
inActiveClient.IdleTimeOutSecs = this.IdleTimeOutSecs.Value;
}

inActiveClient.NamespacePrefix = NamespacePrefix;

Expand Down
6 changes: 4 additions & 2 deletions src/ServiceStack.Redis/RedisNativeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public partial class RedisNativeClient
public const long DefaultDb = 0;
public const int DefaultPort = 6379;
public const string DefaultHost = "localhost";
public const int DefaultIdleTimeOutSecs = 240; //default on redis is 300

internal const int Success = 1;
internal const int OneGb = 1073741824;
Expand All @@ -60,14 +61,13 @@ public partial class RedisNativeClient
internal bool Active { get; set; }
internal PooledRedisClientManager ClientManager { get; set; }

internal int IdleTimeOutSecs = 240; //default on redis is 300
internal long LastConnectedAtTimestamp;

public long Id { get; set; }

public string Host { get; private set; }
public int Port { get; private set; }

/// <summary>
/// Gets or sets object key prefix.
/// </summary>
Expand All @@ -78,6 +78,7 @@ public partial class RedisNativeClient
public int SendTimeout { get; set; }
public int ReceiveTimeout { get; set; }
public string Password { get; set; }
public int IdleTimeOutSecs { get; set; }

public Action<IRedisNativeClient> ConnectionFilter { get; set; }

Expand Down Expand Up @@ -127,6 +128,7 @@ public RedisNativeClient(string host, int port, string password = null, long db
ReceiveTimeout = -1;
Password = password;
Db = db;
IdleTimeOutSecs = DefaultIdleTimeOutSecs;
}

public RedisNativeClient()
Expand Down