write_redis: improve checking the redis connection