| 232 | } |
| 233 | |
| 234 | bool KeyCache::Retrieve(id_t id, const vector<KeyBuf>& kbv) |
| 235 | { |
| 236 | lock_guard<mutex> lock(m_mutex); |
| 237 | |
| 238 | if (!m_enabled) |
| 239 | return false; |
| 240 | |
| 241 | auto it = m_entries.find(id); |
| 242 | |
| 243 | assert(it != m_entries.end()); |
| 244 | |
| 245 | if (it == m_entries.end()) |
| 246 | return false; |
| 247 | |
| 248 | if (!it->second.valid) |
| 249 | return false; |
| 250 | |
| 251 | KeyBuf::CopyBuffers(kbv, it->second.pbuf->m_buf, it->second.pbuf->m_len); |
| 252 | |
| 253 | it->second.accessed = true; |
| 254 | |
| 255 | return true; |
| 256 | } |