return -1;
KCDB *db = ctx;
- kcdbset(db, key, keylen, data, dlen);
- return kcdbecode(db);
+ if (!kcdbset(db, key, keylen, data, dlen))
+ {
+ int ecode = kcdbecode(db);
+ return ecode ? ecode : -1;
+ }
+ return 0;
}
static int hcache_kyotocabinet_delete(void *ctx, const char *key, size_t keylen)
return -1;
KCDB *db = ctx;
- kcdbremove(db, key, keylen);
- return kcdbecode(db);
+ if (!kcdbremove(db, key, keylen))
+ {
+ int ecode = kcdbecode(db);
+ return ecode ? ecode : -1;
+ }
+ return 0;
}
static void hcache_kyotocabinet_close(void **ctx)
/* Not sure if dbecode is reset on success, so better to explicitely return 0
* on success */
bool success = vlput(db, key, keylen, data, dlen, VL_DOVER);
- return success ? 0 : dpecode;
+ return success ? 0 : dpecode ? dpecode : -1;
}
static int hcache_qdbm_delete(void *ctx, const char *key, size_t keylen)
/* Not sure if dbecode is reset on success, so better to explicitely return 0
* on success */
bool success = vlout(db, key, keylen);
- return success ? 0 : dpecode;
+ return success ? 0 : dpecode ? dpecode : -1;
}
static void hcache_qdbm_close(void **ctx)
return -1;
TCBDB *db = ctx;
- bool success = tcbdbput(db, key, keylen, data, dlen);
- return success ? 0 : -1; /* TODO - how to get error code? */
+ if (!tcbdbput(db, key, keylen, data, dlen))
+ {
+ int ecode = tchdbecode(db);
+ return ecode ? ecode : -1;
+ }
+ return 0;
}
static int hcache_tokyocabinet_delete(void *ctx, const char *key, size_t keylen)
return -1;
TCBDB *db = ctx;
- bool success = tcbdbout(db, key, keylen);
- return success ? 0 : -1; /* TODO - how to get error code? */
+ if (!tcbdbout(db, key, keylen))
+ {
+ int ecode = tchdbecode(db);
+ return ecode ? ecode : -1;
+ }
+ return 0;
}
static void hcache_tokyocabinet_close(void **ctx)