Introduce cache and generator factory interface