I wanna to store key(url) & value(jpg image) in leveldb. As it is said,
Keys and values are arbitrary byte arrays.
how can I use the DB::Get API?
Slice does not own the memory (just points to it), so returning a Slice would mean that the caller should free the memory.
So a type with value semantics is needed.
The natural value for binary array would be std::vector<uint8_t>, as it implies so. But std::string can also be used instead (as you pointed out in your answer), and it is more useful if you expect to read a real string (no casting needed).
The main problem is that the reason is not documented, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With