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

Method NewWriteableCacheFile

src/leveldb/persistent_cache/persistent_cache_impl.cc:257–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255void PersistentCacheImpl::ForceEvict(CacheFile* file) { metadata_.ForceEvict(file); }
256
257Status PersistentCacheImpl::NewWriteableCacheFile(const std::string& path,
258 WriteableCacheFile** file) {
259 std::lock_guard<std::mutex> _(lock_);
260 auto real_path = GetCachePath() + path + "." + std::to_string(writer_cache_id_) + ".rc";
261 std::unique_ptr<WriteableCacheFile> f(new WriteableCacheFile{
262 writer_cache_id_, opt_.env, opt_.env_opt, real_path, opt_.write_retry_times, this});
263
264 auto status = f->Create();
265
266 if (!status.ok()) {
267 return status;
268 }
269
270 LEVELDB_LOG("Created cache file %s\n", f->Path().c_str());
271
272 ++writer_cache_id_;
273
274 auto success = metadata_.AddCacheFile(f.get());
275 assert(success);
276 *file = f.release();
277 return Status::OK();
278}
279
280Status PersistentCacheImpl::MakeRoomForWrite(int64_t size) {
281 std::lock_guard<std::mutex> _(lock_);

Callers

nothing calls this directly

Calls 6

AddCacheFileMethod · 0.80
CreateMethod · 0.45
okMethod · 0.45
PathMethod · 0.45
getMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected