<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 基于云存儲實(shí)現用Windows Azure Storage增強應用程序的引擎

基于云存儲實(shí)現用Windows Azure Storage增強應用程序的引擎

作者: 時(shí)間:2018-09-11 來(lái)源:網(wǎng)絡(luò ) 收藏

本文引用地址:http://dyxdggzs.com/article/201809/388914.htm

  現在,我們需要一個(gè)簡(jiǎn)單的包裝來(lái)與我們的隊列交互。從本質(zhì)上說(shuō),我們需要能夠將消息插入隊列,獲取任何掛起的消息并清除該隊列(請參見(jiàn)圖 3)。

  圖 3 用于與隊列交互的包裝

namespace HollywoodHackers..Queue 
{ 
  public class StdQueueT> : 
  Base where T : QueueMessageBase, new() 
  { 
    protected CloudQueue queue; 
    protected CloudQueueClient client; 
 
    public StdQueue(string queueName) 
    { 
      client = new CloudQueueClient 
      (Base.QueueBaseUri, StorageBase.Credentials); 
      queue = client.GetQueueReference(queueName); 
      queue.CreateIfNotExist(); 
    } 
    public void AddMessage(T message) 
    { 
      CloudQueueMessage msg = 
      new CloudQueueMessage(message.ToBinary()); 
      queue.AddMessage(msg); 
    } 
    public void DeleteMessage(CloudQueueMessage msg) 
    { 
      queue.DeleteMessage(msg); 
    } 
    public CloudQueueMessage GetMessage() 
    { 
      return queue.GetMessage(TimeSpan.FromSeconds(60)); 
    } 
  } 
  public class ToastQueue : StdQueueToastQueueMessage> 
  { 
    public ToastQueue() 
      : base(toasts) 
    { 
    } 
  } 
}

我們還需要為表存儲設置一個(gè)包裝,以便在用戶(hù)登錄到站點(diǎn)之前可以存儲用戶(hù)通知??梢允褂?PartitionKey(行集合的標識符)和 RowKey(可唯一標識特定分區中的每個(gè)單獨行)組織表數據。選擇 PartitionKey 和 RowKey 使用的數據是在使用表存儲時(shí)所做的最重要的設計決策之一。

  這些特點(diǎn)允許跨存儲節點(diǎn)進(jìn)行負載平衡,并在應用程序中提供內置的可伸縮性選項。不考慮數據的數據中心關(guān)聯(lián)性,使用同一分區鍵的表存儲中的行將保留在相同的物理數據存儲中。因為針對每個(gè)用戶(hù)存儲對應的消息,所以分區鍵將是 UserName,而 RowKey 則成為標識每行的 GUID(請參見(jiàn)圖 4)。

  圖 4 表存儲的包裝

namespace HollywoodHackers.Storage.Repositories 
{ 
  public class UserTextNotificationRepository : StorageBase 
  { 
    public const string EntitySetName = 
    UserTextNotifications; 
    CloudTableClient tableClient; 
    UserTextNotificationContext notificationContext; 
    public UserTextNotificationRepository() 
      : base() 
    { 
      tableClient = new CloudTableClient 
      (StorageBase.TableBaseUri, StorageBase.Credentials); 
      notificationContext = new UserTextNotificationContext 
      (StorageBase.TableBaseUri,StorageBase.Credentials); 
 
      tableClient.CreateTableIfNotExist(EntitySetName); 
    } 
    public UserTextNotification[] 
    GetNotificationsForUser(string userName) 
    { 
      var q = from notification in 
          notificationContext.UserNotifications 
          where notification.TargetUserName == 
          userName select notification; 
      return q.ToArray(); 
    } 
    public void AddNotification 
    (UserTextNotification notification) 
    { 
      notification.RowKey = Guid.NewGuid().ToString(); 
      notificationContext.AddObject 
      (EntitySetName, notification); 
      notificationContext.SaveChanges(); 
    } 
  } 
}



關(guān)鍵詞: Windows Storage Azure 云存儲

評論


相關(guān)推薦

技術(shù)專(zhuān)區

国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>