refactor redis connection