Closed wlandau closed 6 years ago
This happens at a higher level already:
> st <- storr::storr_rds(tempfile())
> st$set_value
function (value, use_cache = TRUE)
{
value_ser <- self$serialize_object(value)
hash <- self$hash_raw(value_ser)
if (!(use_cache && exists0(hash, self$envir))) {
if (!self$driver$exists_object(hash)) {
value_send <- if (self$traits$accept == "object")
value
else value_ser
self$driver$set_object(hash, value_send)
}
if (use_cache) {
assign(hash, value, self$envir)
}
}
invisible(hash)
}
<environment: 0x22d8040>
The self$driver$exists_object
call here prevents the object being set a second time. This was one of the main things I wanted in storr in the first place!
Are you seeing some case where this is not happening?
Hmm... I must have missed that before, sorry. It's clear to me now.
Diving from
$set()
down totry_write_serialized_rds()
for an RDS cache, I do not see anything to prevent the same object from being written twice.