Line data Source code
1 : #include "storage.hpp"
2 :
3 104 : bool storage::set(const std::string& key, const std::string& val)
4 : {
5 104 : std::lock_guard<std::mutex> lk(_mutex);
6 104 : return _storage.emplace(key,val).second;
7 : }
8 :
9 106 : bool storage::get(const std::string& key, std::string* val) const
10 : {
11 106 : if ( val!=nullptr )
12 106 : val->clear();
13 106 : std::lock_guard<std::mutex> lk(_mutex);
14 106 : auto itr = _storage.find(key);
15 106 : if ( itr == _storage.end() )
16 1 : return false;
17 105 : if ( val!=nullptr )
18 105 : *val = itr->second;
19 105 : return true;
20 : }
21 :
22 :
|