Refactor ToCache method.

Remove rdeps argument, added CacheDep return.