private AmazonS3PathQueryResults QueryPath(string path, PathSearchOption searchOption) { var results = this.GetAmazonS3PathQueryResultsFromCache(path, searchOption); if (results == null) { lock (_lockbox.GetObject(this.CreateAmazonS3PathQueryResultsPrimaryKey(path, searchOption).GetHashCode())) { results = this.GetAmazonS3PathQueryResultsFromCache(path, searchOption); if (results == null) { var files = new List<AmazonS3FileStorageFile>(); var subPaths = new List<string>(); ObjectListResponse response = searchOption != PathSearchOption.AllPaths ? this.GetConnection().ListBucket(this._bucketName, this.MakeKey(path, string.Empty), "", int.MaxValue, "/", new SortedList<string, string>()) : this.GetConnection().ListBucket(this._bucketName, this.MakeKey(path, string.Empty), "", int.MaxValue, new SortedList<string, string>()); foreach (var commonPrefixEntry in response.CommonPrefixEntries) subPaths.Add(this.GetPath(commonPrefixEntry.Prefix, false)); foreach (var entry in response.Entries) { string filePath = GetPath(entry.Key); string fileName = GetFileName(entry.Key); AmazonS3FileStorageFile file = this.GetAmazonS3FileStorageFileFromCache(filePath, fileName); if (file == null) { lock (_lockbox.GetObject(this.CreateAmazonS3FileStorageFilePrimaryKey(filePath, fileName).GetHashCode())) { file = this.GetAmazonS3FileStorageFileFromCache(filePath, fileName); if (file == null) { file = new AmazonS3FileStorageFile(this.FileStoreKey, filePath, fileName, (int)entry.ContentLength); this.PushAmazonS3FileStorageFileToCache(file, filePath, fileName); } } } files.Add(file); } results = new AmazonS3PathQueryResults(subPaths, files); this.PushAmazonS3PathQueryResultsToCache(results, path, searchOption); } } } return results; }
private void PushAmazonS3PathQueryResultsToCache(AmazonS3PathQueryResults results, string path, PathSearchOption searchOption) { var key = this.CreateAmazonS3PathQueryResultsPrimaryKey(path, searchOption); Evolution.Extensibility.Caching.Version1.CacheService.Put(key, results, CacheScope.Context | CacheScope.Process); }