Ara*_*and 5 connection azure azure-storage
在.NET中如何使用Windows Azure Blob存储服务一文中,以下代码用于演示如何上载文件
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
// Create or overwrite the "myblob" blob with contents from a local file.
using (var fileStream = System.IO.File.OpenRead(@"path\myfile"))
{
blockBlob.UploadFromStream(fileStream);
}
Run Code Online (Sandbox Code Playgroud)
如果您有一个长时间运行的服务接受文件并将它们存储在blob存储中,您每次都会执行所有这些步骤吗?或者你可能会有一个引用blockBlob
了多个请求的类?多少(如果有的话)可以缓存和使用多个请求?(我猜这意味着线程)
我同意@knightpfhor,没有什么可以缓存的.在调用UploadFromStream之前,不会调用长时间运行的事务.一切都在记忆中,构建物体.
这不像是一个Sql Connection,程序员可以找到缓存连接的聪明方法,因为打开它们很昂贵 - 这就是REST调用,因此每个数据更改操作都是https调用,并且之前的所有准备工作都很简单 - 重量对象操纵
归档时间: |
|
查看次数: |
600 次 |
最近记录: |