MCPcopy Create free account
hub / github.com/baidu/tera / Insert

Method Insert

src/leveldb/persistent_cache/persistent_cache_impl.cc:309–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307}
308
309bool PersistentCacheImpl::Insert(const Slice& key, CacheFile* file) {
310 std::lock_guard<std::mutex> _(lock_);
311 uint64_t cache_id;
312 if (metadata_.Lookup(key, &cache_id)) {
313 LEVELDB_LOG("File already exists, force evict it: %s\n", key.ToString().c_str());
314 ForceEvict(key);
315 }
316
317 // Insert file to meta data;
318 auto file_in_meta = metadata_.Lookup(file->cacheid());
319 assert(file_in_meta.get() == file);
320
321 auto f_info = metadata_.Insert(key, file);
322 metadata_size_.Set(metadata_.GetDBSize());
323
324 if (!f_info) {
325 return false;
326 }
327
328 file->SetInfo(f_info);
329 return true;
330}
331
332std::vector<std::string> PersistentCacheImpl::GetAllKeys() { return metadata_.GetAllKeys(); }
333

Callers

nothing calls this directly

Calls 7

cacheidMethod · 0.80
GetDBSizeMethod · 0.80
SetInfoMethod · 0.80
LookupMethod · 0.45
ToStringMethod · 0.45
getMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected