I've been having problems designing an effective caching mechanism. The mechanism is to be used as part of a project developing scientific software.
The goal is to save computation time by loading results of identical computations done in the past.
The problem I've been encountering is how to know if a computation is identical to a previous one. Checking the input parameters can be sufficient in most cases, but sometimes the code changes, and then even though the input parameters can be identical, the results may differ.
The problem is that modifying the code now needs to be coupled with clearing the cache, in case that code creates cached results. This is a manual step which is error-prone. Failure can cause the results to stay the same, even after code changes have been made, leading to bugs or erroneous conclusions.
I was wondering if there is any mechanism for caching which can solve, or somehow help avoid this pitfall.
Thanks, Ofer