Add context manager to cache, modify ensemble.py to use it