Stores value under key, replacing any existing value unless overwrite
is FALSE.
Arguments
- txn
An
mdbx_txnobject frommdbx_txn_begin(), opened withwrite = TRUE.- key
A raw vector, or a single string, which is stored as its UTF-8 bytes.
- value
A raw vector, or a single string, which is stored as its UTF-8 bytes. Use
serialize(x, NULL)for an arbitrary R object.- overwrite
If
FALSE, leave an existing value alone and returnFALSEinstead of replacing it.- db
An
mdbx_dbiobject frommdbx_dbi_open()naming a database to address instead of the unnamed main one, orNULLfor the main database.
Value
TRUE if the value was stored, FALSE if overwrite = FALSE and
the key already existed. Returned invisibly.
Examples
path <- tempfile(fileext = ".mdbx")
env <- mdbx_env_open(path)
mdbx_with_write(env, function(txn) {
mdbx_put(txn, "k", "first")
# Refuses to replace, and says so.
mdbx_put(txn, "k", "second", overwrite = FALSE)
})
mdbx_env_close(env)
unlink(c(path, paste0(path, "-lck")))