1 #include "timestamp_manager.h" 2 3 #include "cache_manager.h" 4 #include "indexer.h" 5 GetLastCachedModificationTime(ICacheManager * cache_manager,const std::string & path)6optional<int64_t> TimestampManager::GetLastCachedModificationTime( 7 ICacheManager* cache_manager, 8 const std::string& path) { 9 { 10 std::lock_guard<std::mutex> guard(mutex_); 11 auto it = timestamps_.find(path); 12 if (it != timestamps_.end()) 13 return it->second; 14 } 15 IndexFile* file = cache_manager->TryLoad(path); 16 if (!file) 17 return nullopt; 18 19 UpdateCachedModificationTime(path, file->last_modification_time); 20 return file->last_modification_time; 21 } 22 UpdateCachedModificationTime(const std::string & path,int64_t timestamp)23void TimestampManager::UpdateCachedModificationTime(const std::string& path, 24 int64_t timestamp) { 25 std::lock_guard<std::mutex> guard(mutex_); 26 timestamps_[path] = timestamp; 27 } 28