Erroneous Implementation for Test Cases

For the article Memory-Mapped-Shared-DB-Problem, the backend implementation does not respect the test cases displayed on the interface; for both the test cases, key1, key2 and nonexistent are the keys used to invoke the get() function.

By running std::cout in the get() function’s body, I got this output. Kindly check and fix this, thank you!

get function:

std::optional<std::string> get(const std::string& key) {
    std::cout << key << ':';
    if (__cache__.count(key)) {
        return std::string(records[__cache__[key]].value);
    }
    return std::nullopt;
}

Results:

Thanks for the heads up. Fixing this :-1: