Say I setup memoization with Joblib as follows (using the solution provided here):
from tempfile import mkdtemp
cachedir = mkdtemp()
from joblib import Memory
memory = Memory(cachedir=cachedir, verbose=0)
@memory.cache
def run_my_query(my_query)
...
return df
And say I define a couple of queries, query_1
and query_2
, both of them take a long time to run.
I understand that, with the code as it is:
The second call with either query, would use the memoized output, i.e:
run_my_query(query_1) run_my_query(query_1) # <- Uses cached output run_my_query(query_2) run_my_query(query_2) # <- Uses cached output
I could use
memory.clear()
to delete the entire cache directory
But what if I want to re-do the memoization for only one of the queries (e.g. query_2
) without forcing a delete on the other query?