1

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;
    }
}
Angelo Badellino
  • 2,141
  • 2
  • 24
  • 45

1 Answers1

2

Call a Redis Operation like Ping():

using (var redis = redisPool.GetClient())
{
    return ((IRedisNativeClient)redis).Ping()
        ? RedisCacheProviderStatus.Available
        : RedisCacheProviderStatus.NotAvailable;
}
mythz
  • 141,670
  • 29
  • 246
  • 390