memory-based caching for infer() -- lightly tested but appears to work