MDL-33430 Add caching into choose_repository() method