An Embeddable Datastore Engine |
Tweet |
Follow @Vedis |
Vedis C/C++ API Reference - DBM Methods.
vedis *pStore,
const void *pKey,int nKeyLen,
void *pBuf,
vedis_int64 *pSize /* IN: Buffer Size / OUT: Record Data Size */
);
Inside foreign command via call context:
int vedis_context_kv_fetch(
vedis_context *pCtx,
const void *pKey,int nKeyLen,
void *pBuf,
vedis_int64 *pSize /* IN: Buffer Size / OUT: Record Data Size */
);
Fetch a raw record from the database.
Description
Fetch a record from the database and copy its content to the user supplied buffer. This interface support both dynamically and statically allocated buffer.
The recommended interface for extracting very large data from the database is vedis_kv_fetch_callback() where the user simply need to supply a consumer callback instead of a buffer which may be unacceptable when dealing with very large records.
The vedis_context_kv() family of functions is similar to their standard counterpart (i.e. vedis_kv_()) except that they expect a vedis_context pointer as their first argument which mean that they are designed to be invoked only from a foreign command.
Parameters
pStore |
Vedis datastore handle. |
pKey
|
Record key. |
nKeyLen
|
pKey length. If the nKeyLen argument is less than zero, then pKey is read up to the first zero terminator. If nKeyLen is non-negative, then it is the maximum number of bytes read from pKey. |
pBuf
|
User supplied buffer where record content is copied in. |
pSize
|
IN: Supplied
buffer (pBuf) size in bytes. OUT: Reccord data size in bytes or the amount of data copied in pBuf if the given buffer is too short. |
Return value
VEDIS_NOTFOUND: Nonexistent record.
VEDIS_BUSY: Another thread or process have an exclusive lock on the database. In this case, the caller should wait until the lock holder relinquish it.
VEDIS_IOERR: OS specific error.
VEDIS_NOMEM: Out of memory (Unlikely scenario).
For a human-readable error message, you can extract the database error log via vedis_config() with a configuration verb set to VEDIS_CONFIG_ERR_LOG.
See also