Use cache factory to construct caches.

Change-Id: Idee2230ab3bfa44127943ac8bc2ec596b7982060