refactor pull request/redis handling code