AlexanderMihail / seastar_db

A key-value database engine with REST interface
http://seastar.io
Apache License 2.0
0 stars 0 forks source link

Table::set and Table::get should return bool and pass the result string as ref-argument. #5

Closed AlexanderMihail closed 3 months ago

AlexanderMihail commented 3 months ago

Table::set should return false if the key is already present, rather than update the value. Table::get should return false if the key is not present, rather than return "" which should be a legal value.

AlexanderMihail commented 3 months ago

The newest signatures for Table::get and Table::set are:

https://github.com/AlexanderMihail/seastar_db/blob/4df6de30988b197b107c4857186da4c7276a4994/demos/db_demo.cc#L457 https://github.com/AlexanderMihail/seastar_db/blob/4df6de30988b197b107c4857186da4c7276a4994/demos/db_demo.cc#L568

The empty string is now an accepted value. Table::set prevents multiple insertions and also updating a key that doesn't exist. Table::get returns a pair of bool and cache iterator. The retrieved value is in the string&value parameter. The second return value is the iterator to the corresponding cache line. Table::set first does a get, then uses the iterator get returns.

Relates to #6.