Мы недавно переехали в хранилище файлов Azure. Мы используем CloudFileClient
и CloudFileShare
для доступа к файлам.
В настоящее время мы создаем их при каждом вызове, который кажется неэффективным. Может ли что-либо из этого быть кэшировано, либо на уровне функции, либо в виде статического экземпляра (как вы бы HttpClient
)?
Пример метода, который мы используем
private async Task<CloudFile> GetFileRef(string directory, string filenameAndExtension)
{
// Could this be static / cached?
var client = this.storageAccount.CreateCloudFileClient();
// Could this be static / cached?
var share = client.GetShareReference(this.azureFileShareReference);
// Could this be static / cached?
if (!await share.ExistsAsync())
{
throw new ArgumentNullException($"Azure share {this.azureFileShareReference} does not exist");
}
// Could this be static / cached?
var rootRef = share.GetRootDirectoryReference();
// Could this be static / cached?
var dirRef = rootRef.GetDirectoryReference(directory);
return dirRef.GetFileReference(filenameAndExtension);
}