Andrew Sinclair - 344 - Dec 9, 2013

I have recently upgraded to ServiceStack 4 (purchased a licence) and have a question.

I am using the Redis Typed Client (IRedisTypedClient) and noticed that it is no longer implementing iDisposable so I cannot use a “using” pattern to use and dispose the client.

How do you suggest I properly dispose of the client once I have called GetClient and used it? I have searched the documentation but cannot find an answer.

Thanks in advance.

It was removed because it was misleading, the typed client is just a wrapper around the parent IRedisClient connection, i.e. it doesn’t have a connection that needs to be disposed, so doesn’t need disposing.

Andrew Sinclair:

Do I still need to dispose of the parent IRedisClient after using the IRedisTypedClient? And if so can you show me some example code? Thanks.

just need to dispose of the parent client when you’ve finished using it, e.g:

using (var redis = redisManager.GetClient())
  var redisUsers = redis.As<User>();
  var user = redisUsers.GetById(1);

i.e. the typed client (redisUsers) doesn’t need disposing and the using statement just disposes the default redis client as normal.

Andrew Sinclair:

Thanks for your help Demis, all working well now.