quasardb C API
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions
Integer operations

Functions

QDB_API_LINKAGE qdb_error_t qdb_int_put (qdb_handle_t handle, const char *alias, qdb_int_t integer, qdb_time_t expiry_time)
 Creates a new signed 64-bit integer. More...
 
QDB_API_LINKAGE qdb_error_t qdb_int_update (qdb_handle_t handle, const char *alias, qdb_int_t integer, qdb_time_t expiry_time)
 Creates or updates a signed 64-bit integer. More...
 
QDB_API_LINKAGE qdb_error_t qdb_int_get (qdb_handle_t handle, const char *alias, qdb_int_t *integer)
 Retrieves the value of a signed 64-bit integer. More...
 
QDB_API_LINKAGE qdb_error_t qdb_int_add (qdb_handle_t handle, const char *alias, qdb_int_t addend, qdb_int_t *result)
 Atomically increases or decreases a signed 64-bit integer. More...
 

Detailed Description

Function Documentation

QDB_API_LINKAGE qdb_error_t qdb_int_add ( qdb_handle_t  handle,
const char *  alias,
qdb_int_t  addend,
qdb_int_t result 
)

Atomically increases or decreases a signed 64-bit integer.

The specified entry will be atomically increased (or decreased) according to the given addend value:

  • To increase the value, specify a positive addend
  • To decrease the value, specify a negative addend

The function return the result of the operation.

The entry must already exist. If the entry is not an integer, the function will return qdb_e_incompatible_type.

Parameters
handleA valid handle previously initialized by qdb_open or qdb_open_tcp.
aliasA pointer to a null-terminated UTF-8 string representing the alias of the entry.
addendThe value to add to the existing value.
resultA pointer to an integer that will receive the current value of the entry, if successful.
Returns
A qdb_error_t code indicating success or failure.
See Also
qdb_int_put, qdb_int_update, qdb_int_get
QDB_API_LINKAGE qdb_error_t qdb_int_get ( qdb_handle_t  handle,
const char *  alias,
qdb_int_t integer 
)

Retrieves the value of a signed 64-bit integer.

Atomically retrieves the value of an existing 64-bit integer.

If the entry is not an integer, the function will return qdb_e_incompatible_type.

Parameters
handleA valid handle previously initialized by qdb_open or qdb_open_tcp.
aliasA pointer to a null-terminated UTF-8 string representing the alias of the entry.
integerA pointer to an integer that will receive the current value of the entry, if successful.
Returns
A qdb_error_t code indicating success or failure.
See Also
qdb_int_put, qdb_int_update, qdb_int_add
QDB_API_LINKAGE qdb_error_t qdb_int_put ( qdb_handle_t  handle,
const char *  alias,
qdb_int_t  integer,
qdb_time_t  expiry_time 
)

Creates a new signed 64-bit integer.

Atomically creates an entry of the given alias and sets it to a cross-platform signed 64-bit integer. If the entry already exists, the function returns an error.

You can specify an expiry or use qdb_never_expires if you don't want the entry to expire.

If you want to create or update an entry use qdb_int_update.

The value will be correctly translated independently of the endianness of the client's platform.

Parameters
handleA valid handle previously initialized by qdb_open or qdb_open_tcp.
aliasA pointer to a null-terminated UTF-8 string representing the alias of the entry.
integerThe value to which the integer must be set.
expiry_timeAn optional absolute expiry time expressed in UTC UNIX epoch.
Returns
A qdb_error_t code indicating success or failure.
See Also
qdb_int_update, qdb_int_get, qdb_int_add
QDB_API_LINKAGE qdb_error_t qdb_int_update ( qdb_handle_t  handle,
const char *  alias,
qdb_int_t  integer,
qdb_time_t  expiry_time 
)

Creates or updates a signed 64-bit integer.

Atomically updates an entry of the given alias to the provided value. If the entry doesn't exist, it will be created. If the entry is not an integer, the function will return qdb_e_incompatible_type.

You can specify an expiry time or use qdb_never_expires if you don't want the entry to expire.

Parameters
handleA valid handle previously initialized by qdb_open or qdb_open_tcp.
aliasA pointer to a null-terminated UTF-8 string representing the alias of the entry.
integerThe value to which the integer must be set.
expiry_timeAn optional absolute expiry time expressed in UTC UNIX epoch.
Returns
A qdb_error_t code indicating success or failure.
See Also
qdb_int_put, qdb_int_get, qdb_int_add