NuDB Logo

PrevUpHomeNext

basic_store::insert

Insert a value.

Synopsis
void
insert(
    void const* key,
    void const* data,
    nsize_t bytes,
    error_code& ec);
Description

This function attempts to insert the specified key/value pair into the database. If the key already exists, ec is set to key_exists. If an error occurs, ec is set to the corresponding error.

Requirements

The database must be open.

Thread safety

Safe to call concurrently with any function except basic_store::close.

Remarks

If the implementation encounters an error while committing data to the database, this function will immediately return with ec set to the error which occurred. All subsequent calls to basic_store::insert will return the same error until the database is closed.

Parameters

Name

Description

key

A buffer holding the key to be inserted. The size of the buffer should be at least the key_size associated with the open database.

data

A buffer holding the value to be inserted.

bytes

The size of the buffer holding the value data. This value must be greater than 0 and no more than 0xffffffff.

ec

Set to the error, if any occurred.


PrevUpHomeNext