lib: implement basic caching in the `Engine`