public void PutToCache(PutRecordsRequest putRecordsRequest) { LOGGER.InfoFormat("Put records to cache, record size: {0}, cache dir: {1}.", putRecordsRequest.Records.Count, disConfig.GetDataCacheDir()); string data = JsonConvert.SerializeObject(putRecordsRequest); //synchronized(this) lock (this) { if (NeedToArchive(data)) { // 缓存临时文件归档 LOGGER.DebugFormat("Need to archive cache tmp file, filename: '{0}'.", dataTmpFileName); Archive(); } if (HasEnoughSpace(data)) { WriteToFile(data); } else { LOGGER.ErrorFormat("Put to cache failed, cache space is not enough, configured max dir size: {0}.", disConfig.GetDataCacheDiskMaxSize()); } } }