| 206 | } |
| 207 | |
| 208 | bool KeyCache::Store(id_t id, const BYTE* ptr, size_t len) |
| 209 | { |
| 210 | lock_guard<mutex> lock(m_mutex); |
| 211 | |
| 212 | if (!m_enabled) |
| 213 | return true; |
| 214 | |
| 215 | auto it = m_entries.find(id); |
| 216 | |
| 217 | if (it == m_entries.end()) |
| 218 | return false; |
| 219 | |
| 220 | assert(it->second.pbuf->m_len == len); |
| 221 | |
| 222 | if (it->second.pbuf->m_len < len) |
| 223 | return false; |
| 224 | |
| 225 | memcpy(it->second.pbuf->m_buf, ptr, len); |
| 226 | |
| 227 | it->second.valid = true; |
| 228 | it->second.accessed = true; |
| 229 | m_valid_count++; |
| 230 | |
| 231 | return true; |
| 232 | } |
| 233 | |
| 234 | bool KeyCache::Retrieve(id_t id, const vector<KeyBuf>& kbv) |
| 235 | { |