Reputation: 2191
I am trying to figure out how check the availability of the Redis Client. The simple action of calling the client, will give me this information? Is there a better method?
private RedisManagerPool redisPool;
public RedisCacheProviderStatus ServiceStatus()
{
try
{
using (IRedisClient client = redisPool.GetClient())
{
}
return RedisCacheProviderStatus.Available;
}
catch (Exception)
{
return RedisCacheProviderStatus.NotAvailable;
}
}
Upvotes: 1
Views: 1821
Reputation: 143284
Call a Redis Operation like Ping()
:
using (var redis = redisPool.GetClient())
{
return ((IRedisNativeClient)redis).Ping()
? RedisCacheProviderStatus.Available
: RedisCacheProviderStatus.NotAvailable;
}
Upvotes: 2