Refactor postgresql/redis service classes into common superclass