stash_set() stores a value under a key, replacing any entry there.
stash_mset() stores every element of a named list, in one transaction.
stash_delete() removes the entries for the keys given, in one transaction;
keys with no entry are ignored.
All three return the stash invisibly, so they chain with |>.
Usage
stash_set(stash, key, value, ..., expire = NULL, tags = NULL, codec = NULL)
stash_mset(stash, values, ..., expire = NULL, tags = NULL, codec = NULL)
stash_delete(stash, keys)Arguments
- stash
A stash, from
stash().- key
A key.
- value
The value to store.
- ...
Must be empty.
- expire
When the entry expires:
NULLorInffor never; a number of seconds from now (zero or less means already expired); a difftime from now; or a POSIXct for an absolute time. An expired entry is absent to every read at once, andstash_expire()reclaims its space.A character vector of up to 16 tags, each at most 256 bytes, to group entries for
stash_evict()andstash_entries().- codec
The codec to write with, or
NULLfor the stash's default. Seecodec().- values
A named list: each name is a key, each element its value.
- keys
A character vector of keys, or a list of keys.
Examples
s <- local_stash()
s |>
stash_set("a", 1) |>
stash_mset(list(b = "two", c = 3:5))
#> Error in stash_set(s, "a", 1): This stash has been closed.
stash_keys(s)
#> Error in stash_keys(s): This stash has been closed.
stash_delete(s, c("a", "b"))
#> Error in stash_delete(s, c("a", "b")): This stash has been closed.
stash_keys(s)
#> Error in stash_keys(s): This stash has been closed.