refactor credentials cache