oo <- options(onetime.dir = tempdir(check = TRUE))
id <- sample(10000L, 1L)
for (n in 1:3) {
onetime_do(print("printed once"), id = id)
}
# expiry is "backward-looking":
id2 <- sample(10000L, 1L)
expiry <- as.difftime(1, units = "secs")
onetime_do(print("Expires quickly, right?"), id = id2, expiry = expiry)
Sys.sleep(2)
onetime_do(print("This won't be shown..."), id = id2)
onetime_do(print("... but this will"), id = id2, expiry = expiry)
onetime_reset(id = id)
onetime_reset(id = id2)
options(oo)
Run the code above in your browser using DataLab