If I insert a value into a HamsterDB database with the flag HAM_OVERWRITE
, what is the effect when the key doesn't already exists?
I am keeping track of the highest serial number in my program and persisting it in a HamsterDB database:
if (serial > high_serial_) {
high_serial_ = serial;
ham::key key((void*)HIGH_SERIAL_KEY, strlen(HIGH_SERIAL_KEY));
ham::record record((void*)&high_serial_, sizeof(high_serial_));
db.insert(&key, &record, HAM_OVERWRITE);
}
Upon starting up the application again, high_serial_
is initialised with the current value stored in the DB:
ham::key key((void*)HIGH_SERIAL_KEY, strlen(HIGH_SERIAL_KEY));
auto record = roll_file_db.find(&key);
But this call is throwing HAM_KEY_NOT_FOUND
. The documentation states that it will simply be inserted if the key doesn't already exist. This is not what I'm experiencing though.