Functions that affect only the cache. More...
Functions | |
ssize_t | nmdb_cache_get (nmdb_t *db, const unsigned char *key, size_t ksize, unsigned char *val, size_t vsize) |
Get the value associated with a key from cache. | |
int | nmdb_cache_set (nmdb_t *db, const unsigned char *key, size_t ksize, const unsigned char *val, size_t vsize) |
Set the value associated with a key, but only in the cache. | |
int | nmdb_cache_del (nmdb_t *db, const unsigned char *key, size_t ksize) |
Delete a key, but only from the cache. | |
int | nmdb_cache_cas (nmdb_t *db, const unsigned char *key, size_t ksize, const unsigned char *oldval, size_t ovsize, const unsigned char *newval, size_t nvsize) |
Perform an atomic compare-and-swap only on the cache. | |
int | nmdb_cache_incr (nmdb_t *db, const unsigned char *key, size_t ksize, int64_t increment, int64_t *newval) |
Atomically increment the value associated with a key only in the cache. |
Functions that affect only the cache.
ssize_t nmdb_cache_get | ( | nmdb_t * | db, | |
const unsigned char * | key, | |||
size_t | ksize, | |||
unsigned char * | val, | |||
size_t | vsize | |||
) |
Get the value associated with a key from cache.
This is just like nmdb_get(), except it only queries the caches, and never the database.
db | connection instance. | |
key | the key. | |
ksize | the key size. | |
[out] | val | buffer where the value will be stored. |
vsize | size of the value buffer. |
int nmdb_cache_set | ( | nmdb_t * | db, | |
const unsigned char * | key, | |||
size_t | ksize, | |||
const unsigned char * | val, | |||
size_t | vsize | |||
) |
Set the value associated with a key, but only in the cache.
This command sets the key's value in the cache, but does NOT affect the backend database. Combining it with nmdb_set() and/or nmdb_set_sync() is not recommended, because consistency issues may arise.
db | connection instance. | |
key | the key. | |
ksize | the key size. | |
val | the value | |
vsize | size of the value. |
int nmdb_cache_del | ( | nmdb_t * | db, | |
const unsigned char * | key, | |||
size_t | ksize | |||
) |
Delete a key, but only from the cache.
This command deletes a key from the cache, but does NOT affect the backend database. Combining it with nmdb_del() and/or nmdb_del_sync() is not recommended, because consistency issues may arise.
db | connection instance. | |
key | the key. | |
ksize | the key size. |
int nmdb_cache_cas | ( | nmdb_t * | db, | |
const unsigned char * | key, | |||
size_t | ksize, | |||
const unsigned char * | oldval, | |||
size_t | ovsize, | |||
const unsigned char * | newval, | |||
size_t | nvsize | |||
) |
Perform an atomic compare-and-swap only on the cache.
This command works just like nmdb_cas(), except it affects only the cache, and not the backend database. Equivalent to atomically doing:
if get_cache(key) == oldval, then set_cache(key, newval)
db | connection instance. | |
key | the key. | |
ksize | the key size. | |
oldval | the old, expected value. | |
ovsize | size of the expected value. | |
newval | the new value to set. | |
nvsize | size of the new value. |
int nmdb_cache_incr | ( | nmdb_t * | db, | |
const unsigned char * | key, | |||
size_t | ksize, | |||
int64_t | increment, | |||
int64_t * | newval | |||
) |
Atomically increment the value associated with a key only in the cache.
This command works just like nmdb_incr(), except it affects only the cache, and not the backend database.
db | connection instance. | |
key | the key. | |
ksize | the key size. | |
increment | the value to add to the current one (can be negative). | |
[out] | newval | pointer to an integer that will be set to the new value. |