From 305acea8d6bbae2488ccd49011fc160989ff59df Mon Sep 17 00:00:00 2001 From: mhanney Date: Thu, 19 Sep 2013 14:17:37 -0700 Subject: [PATCH] made idle timeout settable --- src/ServiceStack.Redis/PooledRedisClientManager.cs | 9 +++++++++ src/ServiceStack.Redis/RedisNativeClient.cs | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ServiceStack.Redis/PooledRedisClientManager.cs b/src/ServiceStack.Redis/PooledRedisClientManager.cs index fa8d4cf8..954aef9f 100644 --- a/src/ServiceStack.Redis/PooledRedisClientManager.cs +++ b/src/ServiceStack.Redis/PooledRedisClientManager.cs @@ -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; } /// /// Gets or sets object key prefix. @@ -233,6 +234,10 @@ public IRedisClient GetClient() { inActiveClient.ReceiveTimeout = this.SocketReceiveTimeout.Value; } + if (this.IdleTimeOutSecs.HasValue) + { + inActiveClient.IdleTimeOutSecs = this.IdleTimeOutSecs.Value; + } inActiveClient.NamespacePrefix = NamespacePrefix; @@ -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; diff --git a/src/ServiceStack.Redis/RedisNativeClient.cs b/src/ServiceStack.Redis/RedisNativeClient.cs index cbd32f6c..d2eb85ae 100644 --- a/src/ServiceStack.Redis/RedisNativeClient.cs +++ b/src/ServiceStack.Redis/RedisNativeClient.cs @@ -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; @@ -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; } - + /// /// Gets or sets object key prefix. /// @@ -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 ConnectionFilter { get; set; } @@ -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()