drop_cache to reset the cache only for particular arguments.R/memoise.R
forget.RdForget past results.
Resets the cache of a memoised function. Use drop_cache to
reset the cache only for particular arguments.
forget(f)memX <- memoise(function() { Sys.sleep(1); runif(1) })
# The forget() function
system.time(print(memX()))
#> [1] 0.4790245
#> user system elapsed
#> 0.002 0.000 1.002
system.time(print(memX()))
#> [1] 0.4790245
#> user system elapsed
#> 0.000 0.000 0.001
forget(memX)
#> [1] TRUE
system.time(print(memX()))
#> [1] 0.4321713
#> user system elapsed
#> 0.001 0.000 1.001