public boolean put(final Txn<T> txn, final T key, final T val,
                     final PutFlags... flags) {
    if (SHOULD_CHECK) {
      requireNonNull(txn);
      requireNonNull(key);
      requireNonNull(val);
      txn.checkReady();
      txn.checkWritesAllowed();
    }
    txn.kv().keyIn(key);
    txn.kv().valIn(val);
    final int mask = mask(flags);
    final int rc = LIB.mdb_put(txn.pointer(), ptr, txn.kv().pointerKey(), txn
                               .kv().pointerVal(), mask);
    if (rc == MDB_KEYEXIST) {
      if (isSet(mask, MDB_NOOVERWRITE)) {
        txn.kv().valOut(); // marked as in,out in LMDB C docs
      } else if (!isSet(mask, MDB_NODUPDATA)) {
        checkRc(rc);
      }
      return false;
    }
    checkRc(rc);
    return true;
  }
public boolean put ( final Txn < T > txn , final T key , final T val , final PutFlags ... flags ) { if ( SHOULD_CHECK ) { requireNonNull ( txn ) ; requireNonNull ( key ) ; requireNonNull ( val ) ; txn . checkReady ( ) ; txn . checkWritesAllowed ( ) ; } txn . kv ( ) . keyIn ( key ) ; txn . kv ( ) . valIn ( val ) ; final int mask = mask ( flags ) ; final int rc = LIB . mdb_put ( txn . pointer ( ) , ptr , txn . kv ( ) . pointerKey ( ) , txn . kv ( ) . pointerVal ( ) , mask ) ; if ( rc == MDB_KEYEXIST ) { if ( isSet ( mask , MDB_NOOVERWRITE ) ) { txn . kv ( ) . valOut ( ) ; } else if ( ! isSet ( mask , MDB_NODUPDATA ) ) { checkRc ( rc ) ; } return false ; } checkRc ( rc ) ; return true ; }
Store a key/value pair in the database.

<p>
This function stores key/data pairs in the database. The default behavior
is to enter the new key/data pair, replacing any previously existing key if
duplicates are disallowed, or adding a duplicate data item if duplicates
are allowed ({@link DbiFlags#MDB_DUPSORT}).

@param txn   transaction handle (not null; not committed; must be R-W)
@param key   key to store in the database (not null)
@param val   value to store in the database (not null)
@param flags Special options for this operation
@return true if the value was put, false if MDB_NOOVERWRITE or
MDB_NODUPDATA were set and the key/value existed already.