Reputation: 146
We have a system that makes about 5000 requests per second to Redis cache. We have been looking for best practices to use ServicStack.Redis client in such scenarios.
Most of our calls are for HashSets using Typed clients as:
RedisClient redisInstance = new RedisClient();
var redisTypedClient = redisInstance.As < CustomObject > ();
var data = redisTypedClient.GetValueFromHash(redisTypedClient.GetHash("hset:SetId"), recordId);
Initially we took "redisInstance" as static object, it worked fine for few requests but once the number of requests increased it started throwing following exception: ServiceStack.Redis.RedisResponseException: Unexpected reply
We changed the "redisInstance" to local object and it started working okay.
We are still a bit perplexed on whether we have used it in the right way or not. So my questions are: Are we using right? Does PooledRedisClientManager is better approach than this? Any other approach?
We have about 10 or 15 different typed redis hash sets that we query very frequently for each user.
Looking for some good advices.
Upvotes: 2
Views: 1431
Reputation: 75
You can try depending on the Manager
this test on the repo show the basic usage with PooledRedisClientManager
using (redisClient = (RedisClient)pool.GetClient())
{
redisClient.Set("test", DateTime.Now);
}
Upvotes: 1