Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 8c62075

Browse files
committed
Add new NamespacePrefix and ConnectTimeout options on RedisEndpoint
1 parent 4c0678e commit 8c62075

5 files changed

Lines changed: 27 additions & 9 deletions

File tree

src/ServiceStack.Redis/RedisEndpoint.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public RedisEndpoint()
1111
Port = RedisNativeClient.DefaultPort;
1212
Db = RedisNativeClient.DefaultDb;
1313

14+
ConnectTimeout = 0;
1415
SendTimeout = -1;
1516
ReceiveTimeout = -1;
1617
IdleTimeOutSecs = RedisNativeClient.DefaultIdleTimeOutSecs;
@@ -27,26 +28,30 @@ public RedisEndpoint(string host, int port, string password = null, long db = Re
2728

2829
public string Host { get; set; }
2930
public int Port { get; set; }
31+
public bool Ssl { get; set; }
32+
public int ConnectTimeout { get; set; }
3033
public int SendTimeout { get; set; }
3134
public int ReceiveTimeout { get; set; }
3235
public int IdleTimeOutSecs { get; set; }
3336
public long Db { get; set; }
3437
public string Client { get; set; }
3538
public string Password { get; set; }
36-
public bool Ssl { get; set; }
3739
public bool RequiresAuth { get { return !string.IsNullOrEmpty(Password); } }
40+
public string NamespacePrefix { get; set; }
3841

3942
protected bool Equals(RedisEndpoint other)
4043
{
4144
return string.Equals(Host, other.Host)
4245
&& Port == other.Port
43-
&& SendTimeout == other.SendTimeout
46+
&& Ssl.Equals(other.Ssl)
47+
&& ConnectTimeout == other.ConnectTimeout
48+
&& SendTimeout == other.SendTimeout
4449
&& ReceiveTimeout == other.ReceiveTimeout
4550
&& IdleTimeOutSecs == other.IdleTimeOutSecs
4651
&& Db == other.Db
4752
&& string.Equals(Client, other.Client)
4853
&& string.Equals(Password, other.Password)
49-
&& Ssl.Equals(other.Ssl);
54+
&& string.Equals(NamespacePrefix, other.NamespacePrefix);
5055
}
5156

5257
public override bool Equals(object obj)
@@ -63,13 +68,15 @@ public override int GetHashCode()
6368
{
6469
var hashCode = (Host != null ? Host.GetHashCode() : 0);
6570
hashCode = (hashCode * 397) ^ Port;
71+
hashCode = (hashCode * 397) ^ Ssl.GetHashCode();
72+
hashCode = (hashCode * 397) ^ ConnectTimeout;
6673
hashCode = (hashCode * 397) ^ SendTimeout;
6774
hashCode = (hashCode * 397) ^ ReceiveTimeout;
6875
hashCode = (hashCode * 397) ^ IdleTimeOutSecs;
6976
hashCode = (hashCode * 397) ^ Db.GetHashCode();
7077
hashCode = (hashCode * 397) ^ (Client != null ? Client.GetHashCode() : 0);
7178
hashCode = (hashCode * 397) ^ (Password != null ? Password.GetHashCode() : 0);
72-
hashCode = (hashCode * 397) ^ Ssl.GetHashCode();
79+
hashCode = (hashCode * 397) ^ (NamespacePrefix != null ? NamespacePrefix.GetHashCode() : 0);
7380
return hashCode;
7481
}
7582
}

src/ServiceStack.Redis/RedisExtensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static RedisEndpoint ToRedisEndpoint(this string connectionString)
6161
foreach (var param in qsParams)
6262
{
6363
var entry = param.Split('=');
64-
var value = entry.Length > 1 ? entry[1] : null;
64+
var value = entry.Length > 1 ? entry[1].UrlDecode() : null;
6565
if (value == null) continue;
6666

6767
var name = entry[0].ToLower();
@@ -81,6 +81,12 @@ public static RedisEndpoint ToRedisEndpoint(this string connectionString)
8181
case "password":
8282
endpoint.Password = value;
8383
break;
84+
case "namespaceprefix":
85+
endpoint.NamespacePrefix = value;
86+
break;
87+
case "connecttimeout":
88+
endpoint.ConnectTimeout = int.Parse(value);
89+
break;
8490
case "sendtimeout":
8591
endpoint.SendTimeout = int.Parse(value);
8692
break;

src/ServiceStack.Redis/ServiceStack.Redis.Signed.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@
156156
<Compile Include="BufferPool.cs" />
157157
<Compile Include="Commands.cs" />
158158
<Compile Include="ConnectionUtils.cs" />
159+
<Compile Include="IHandleClientDispose.cs" />
160+
<Compile Include="RedisManagerPool.cs" />
161+
<Compile Include="RedisClient_Admin.cs" />
159162
<Compile Include="Generic\ManagedListGeneric.cs" />
160163
<Compile Include="Generic\QueuedRedisTypedCommand.cs" />
161164
<Compile Include="Generic\RedisClientsManagerExtensionsGeneric.cs" />
@@ -171,6 +174,7 @@
171174
<Compile Include="Pipeline\RedisCommand.cs" />
172175
<Compile Include="RedisClient_Slowlog.cs" />
173176
<Compile Include="RedisConfig.cs" />
177+
<Compile Include="RedisDataExtensions.cs" />
174178
<Compile Include="RedisEndpoint.cs" />
175179
<Compile Include="RedisPubSubServer.cs" />
176180
<Compile Include="RedisSentinel.cs" />
@@ -191,7 +195,6 @@
191195
<Compile Include="Support\SerializedObjectWrapper.cs" />
192196
<Compile Include="Support\ISerializer.cs" />
193197
<Compile Include="Support\Locking\DisposableDistributedLock.cs" />
194-
<Compile Include="PooledRedisClientManager.Disposable.cs" />
195198
<Compile Include="Support\Queue\IChronologicalWorkQueue.cs" />
196199
<Compile Include="Support\Queue\ISequentialWorkQueue.cs" />
197200
<Compile Include="Support\Queue\ISimpleWorkQueue.cs" />
@@ -222,7 +225,6 @@
222225
<Compile Include="RedisClientFactory.cs" />
223226
<Compile Include="Generic\RedisClientSet.Generic.cs" />
224227
<Compile Include="Generic\RedisClientList.Generic.cs" />
225-
<Compile Include="PooledRedisClientManager.ICacheClient.cs" />
226228
<Compile Include="RedisClient.ICacheClient.cs" />
227229
<Compile Include="Generic\RedisTypedClient.cs" />
228230
<Compile Include="RedisCacheClientFactory.cs" />

src/ServiceStack.Redis/ServiceStack.Redis.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
<Compile Include="BufferPool.cs" />
151151
<Compile Include="Commands.cs" />
152152
<Compile Include="ConnectionUtils.cs" />
153+
<Compile Include="IHandleClientDispose.cs" />
154+
<Compile Include="RedisManagerPool.cs" />
155+
<Compile Include="RedisClient_Admin.cs" />
153156
<Compile Include="Generic\ManagedListGeneric.cs" />
154157
<Compile Include="Generic\QueuedRedisTypedCommand.cs" />
155158
<Compile Include="Generic\RedisClientsManagerExtensionsGeneric.cs" />
@@ -165,6 +168,7 @@
165168
<Compile Include="Pipeline\RedisCommand.cs" />
166169
<Compile Include="RedisClient_Slowlog.cs" />
167170
<Compile Include="RedisConfig.cs" />
171+
<Compile Include="RedisDataExtensions.cs" />
168172
<Compile Include="RedisEndpoint.cs" />
169173
<Compile Include="RedisPubSubServer.cs" />
170174
<Compile Include="RedisSentinel.cs" />
@@ -185,7 +189,6 @@
185189
<Compile Include="Support\SerializedObjectWrapper.cs" />
186190
<Compile Include="Support\ISerializer.cs" />
187191
<Compile Include="Support\Locking\DisposableDistributedLock.cs" />
188-
<Compile Include="PooledRedisClientManager.Disposable.cs" />
189192
<Compile Include="Support\Queue\IChronologicalWorkQueue.cs" />
190193
<Compile Include="Support\Queue\ISequentialWorkQueue.cs" />
191194
<Compile Include="Support\Queue\ISimpleWorkQueue.cs" />
@@ -216,7 +219,6 @@
216219
<Compile Include="RedisClientFactory.cs" />
217220
<Compile Include="Generic\RedisClientSet.Generic.cs" />
218221
<Compile Include="Generic\RedisClientList.Generic.cs" />
219-
<Compile Include="PooledRedisClientManager.ICacheClient.cs" />
220222
<Compile Include="RedisClient.ICacheClient.cs" />
221223
<Compile Include="Generic\RedisTypedClient.cs" />
222224
<Compile Include="RedisCacheClientFactory.cs" />

tests/ServiceStack.Redis.Tests/ServiceStack.Redis.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
<Compile Include="LexTests.cs" />
185185
<Compile Include="LicenseUsageTests.cs" />
186186
<Compile Include="ManagedListGenericTests.cs" />
187+
<Compile Include="RedisClientConfigTests.cs" />
187188
<Compile Include="RedisExtensionTests.cs" />
188189
<Compile Include="Examples\TodoApp.cs" />
189190
<Compile Include="Issues\DomainEventsTests.cs" />

0 commit comments

Comments
 (0)