| 255 | void PersistentCacheImpl::ForceEvict(CacheFile* file) { metadata_.ForceEvict(file); } |
| 256 | |
| 257 | Status 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 | |
| 280 | Status PersistentCacheImpl::MakeRoomForWrite(int64_t size) { |
| 281 | std::lock_guard<std::mutex> _(lock_); |