Write a Value to the Store.
More...
|
| static int | store_gdbm_store (StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen) |
| | Write a Value to the Store - Implements StoreOps::store() -.
|
| |
| static int | store_lmdb_store (StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen) |
| | Write a Value to the Store - Implements StoreOps::store() -.
|
| |
| static int | store_rocksdb_store (StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen) |
| | Write a Value to the Store - Implements StoreOps::store() -.
|
| |
| static int | store_tdb_store (StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen) |
| | Write a Value to the Store - Implements StoreOps::store() -.
|
| |
Write a Value to the Store.
- Parameters
-
| [in] | store | Store retrieved via open() |
| [in] | key | Key identifying the record |
| [in] | klen | Length of the Key string |
| [in] | value | Value to save |
| [in] | vlen | Length of the Value |
- Return values
-
| 0 | Success |
| num | Error, a backend-specific error code |
◆ store_gdbm_store()
| static int store_gdbm_store |
( |
StoreHandle * | store, |
|
|
const char * | key, |
|
|
size_t | klen, |
|
|
void * | value, |
|
|
size_t | vlen ) |
|
static |
Write a Value to the Store - Implements StoreOps::store() -.
Definition at line 94 of file gdbm.c.
96{
97 if (!store || (klen > INT_MAX) || (vlen > INT_MAX))
98 return -1;
99
100 datum dkey = { 0 };
101 datum databuf = { 0 };
102
103
104 GDBM_FILE db = store;
105
106 dkey.dptr = (char *) key;
107 dkey.dsize = klen;
108
109 databuf.dsize = vlen;
110 databuf.dptr = value;
111
112 return gdbm_store(db, dkey, databuf, GDBM_REPLACE);
113}
◆ store_lmdb_store()
| static int store_lmdb_store |
( |
StoreHandle * | store, |
|
|
const char * | key, |
|
|
size_t | klen, |
|
|
void * | value, |
|
|
size_t | vlen ) |
|
static |
Write a Value to the Store - Implements StoreOps::store() -.
Definition at line 262 of file lmdb.c.
264{
265 if (!store)
266 return -1;
267
268 MDB_val dkey = { 0 };
269 MDB_val databuf = { 0 };
270
271
273
274 dkey.mv_data = (void *) key;
275 dkey.mv_size = klen;
276 databuf.mv_data = value;
277 databuf.mv_size = vlen;
279 if (rc != MDB_SUCCESS)
280 {
282 return rc;
283 }
284 rc = mdb_put(sdata->
txn, sdata->
db, &dkey, &databuf, 0);
285 if (rc != MDB_SUCCESS)
286 {
288 mdb_txn_abort(sdata->
txn);
291 }
292 return rc;
293}
#define mutt_debug(LEVEL,...)
static int lmdb_get_write_txn(struct LmdbStoreData *sdata)
Get an LMDB write transaction.
@ TXN_UNINITIALIZED
Transaction is uninitialised.
@ LL_DEBUG2
Log at debug level 2.
MDB_txn * txn
LMDB transaction.
enum LmdbTxnMode txn_mode
Transaction mode.
◆ store_rocksdb_store()
| static int store_rocksdb_store |
( |
StoreHandle * | store, |
|
|
const char * | key, |
|
|
size_t | klen, |
|
|
void * | value, |
|
|
size_t | vlen ) |
|
static |
Write a Value to the Store - Implements StoreOps::store() -.
Definition at line 154 of file rocksdb.c.
156{
157 if (!store)
158 return -1;
159
160
162
165 {
166 rocksdb_free(sdata->
err);
168 return -1;
169 }
170
171 return 0;
172}
rocksdb_t * db
RocksDB database.
rocksdb_writeoptions_t * write_options
Write options.
◆ store_tdb_store()
| static int store_tdb_store |
( |
StoreHandle * | store, |
|
|
const char * | key, |
|
|
size_t | klen, |
|
|
void * | value, |
|
|
size_t | vlen ) |
|
static |
Write a Value to the Store - Implements StoreOps::store() -.
Definition at line 93 of file tdb.c.
95{
96 if (!store)
97 return -1;
98
99
100 TDB_CONTEXT *db = store;
101 TDB_DATA dkey;
102 TDB_DATA databuf;
103
104 dkey.dptr = (unsigned char *) key;
105 dkey.dsize = klen;
106
107 databuf.dsize = vlen;
108 databuf.dptr = value;
109
110 return tdb_store(db, dkey, databuf, TDB_INSERT);
111}