put#

Store a value under a key.

Synopsis#

$txn->put($db, $key, $value);
my $added = $txn->put($db, $key, $value, MDB_NOOVERWRITE);

Flags#

  • none - store, replacing the key’s value; in an MDB_DUPSORT database, add the value to the key’s values.

  • MDB_NOOVERWRITE - store only a key not yet there.

  • MDB_NODUPDATA - in an MDB_DUPSORT database, store only a value the key does not hold yet.

  • MDB_APPEND, MDB_APPENDDUP - the key (value) goes after all the others: a fast load of sorted data; out of order it croaks MDB_KEYEXIST.

What you get back#

True when stored, false when MDB_NOOVERWRITE or MDB_NODUPDATA found the key (value) already there.

Edge cases#

  • In a read transaction it croaks with LMDB’s Permission denied.

  • MDB_RESERVE is refused with a croak.

  • When the data outgrows the environment’s mapsize it croaks MDB_MAP_FULL, and the transaction can only be aborted.

See also#

  • del - removes a key or one value

  • Peta::LMDB::Cursor - put at a cursor