Vedis Users Forum

Issues deleting a key

append delete syn

Hi everyone,

I'm having issues deleting a key in vedis. I tried 'DEL' 'DELETE' 'UNSET'. Regardless of what I've tried, it just won't remove the entry. I test beforehand to make certain it exists, and it returns true. Is there anything I should be checking? Return on the open doesn't return any errors either.

Thanks a lot.

Reply RSS


append delete #1. chm

Make sure the key is already stored there. Could you provide any code samples you have used?

append delete #2. syn

Thanks for the response chm, below is the meat of what's in there. Inserting works great, no problem.

string testkey = "foo";
string vedDB = "testdb";

vedis *vsveddb;
vedis_value *vsvedir;
int vvedsed,vvedsetrn;
const char *vvedsirs;

vvedsed = vedis_open(&vsveddb, vedDB.c_str());

if( vvedsed != VEDIS_OK) {
throw runtime_error("Unable to open the DB!");

vvedsed = vedis_exec_fmt(vsveddb,"EXISTS %s",testkey.c_str());

vvedsirs = vedis_value_to_string(vsvedir,0);

// If it exists, then remove it.
if (vvedsirs != NULL || vvedsirs[0] != 0) {
printf("\nIN THERE\n");

vedis_exec_fmt(vsveddb,"DEL %s",testkey.c_str());
vvedsetrn = vedis_value_to_int(vsvedir);

if (vvedsetrn != VEDIS_OK) {


append delete #3. chm

Your code logic is 90% wrong. I'll post a correct version shortly and you should test with that.

append delete #4. syn

Sure thanks a lot for the response. I thought I had it down pat. :(

append delete #5. dali

I recommend you to play a little bit with the Vedis python binding in order to familiarize your self with the commands and their return value:

You should also check the Vedis shell available here: (bottom page).

append delete #6. syn

Thanks a lot for the feedback. I've refactored my insert code and things are working great so far. The issue is, I've just created a single record:

key: testkey
value: true

I issued this:

vedis_exec_fmt(vedisdb,"DEL %s", keystring.c_str());

Is there anything wrong with that as far as you can tell? That's literally the only code I've used on an already-opened store, and called vedis_commit(vedisdb) after just in case. I appreciate it a lot, thanks again.

append delete #7. syn

Here's output while using vedis_shell:

Simple Vedis Shell
Enter one or more Vedis commands.

Type 'CMD_LIST' for a list of built-in Vedis commands.

Enter a blank line to exit the shell

vedis>SET keystring "true"
vedis>GET keystring
vedis>DEL keystring
vedis>Exiting...comitting the transaction
syn@testbed:~/db-tests$ strings vedisdb

append delete #8. syn

I'll add to this that once I re-opened vedis_shell, GET returned null on the key. However, it still seems to be there in the DB file. Is there a way to completely remove that entry?

Thanks very much again,


#9. chm

This post was deleted by its owner

append delete #10. chm

make sure that keystring.c_str() return the key without trailing garbages, spaces and even the nul terminator. Otherwise, the delete process could not be done.

append delete #11. syn

chm thanks so much. it's still in the file with garbage trimmed, but during a query doesn't return true. It could be another issue going on which I haven't discovered yet. One thing I *did* discover tonight however, is that if i try to use a random ID as the key and it starts with integers, it's seen as key:value e.g.:

key: 1234DnDju93A7dfsjoi

it stores 1234 and upon a GET request, returns DnDju93A7dfsjoi. Is there a way to avoid that? I was wrongly impatient to label anything working incorrectly, it was moreso my lack of time spent with vedis and my sincerest apologies. So far, it's working great aside from the couple of caveats I've named.

Thank you!


append delete #12. chm

I think that the way you deal with strings is wrong (I mean here the cstring class you seem using). Again test with the vedis shell and report you status. I'll be glad to help.


(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.