| 62 | } |
| 63 | |
| 64 | FileInfo* PersistentCacheMetaData::InsertWithoutPutDb(const Slice& key, uint64_t cache_id) { |
| 65 | std::unique_ptr<FileInfo> f_info(new FileInfo(key, cache_id)); |
| 66 | if (!cache_id_index_.Insert(f_info.get())) { |
| 67 | LEVELDB_LOG("Insert key failed %s , cache_id %lu\n", key.ToString().c_str(), cache_id); |
| 68 | return nullptr; |
| 69 | } else { |
| 70 | std::lock_guard<std::mutex> _(keys_lock_); |
| 71 | keys_.emplace(key.ToString()); |
| 72 | } |
| 73 | return f_info.release(); |
| 74 | } |
| 75 | |
| 76 | FileInfo* PersistentCacheMetaData::Insert(const Slice& key, CacheFile* cache_file) { |
| 77 | auto finfo = InsertWithoutPutDb(key, cache_file->cacheid()); |