Windows Azure 系列-- Azure Redis Cache的配置和使用

來源:互聯網
上載者:User

標籤:

如果還沒有配置Azure Power shell 可以參照這裡進行配置:
http://blog.csdn.net/lan_liang/article/details/46850221

開啟Azure Power Shell


1. 運行
Add-AzureAccount

(如果已經添加就不用了)


2. 運行 
New-AzureManagedCache -Name mycache -Location "South Central US" -Sku Basic -Memory 128MB


進到Azure Cache頁面,可以看到Cache正在建立



3. 進入https://portal.azure.com/#create/Microsoft.Cache.1.0.4建立Cache





4. 點擊菜單Redis Caches 可以看到redis已經建立好了:





5. 安裝nuget package




6. Console Application的代碼:

static void Main(string[] args)        {            ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("your_domain.redis.cache.windows.net,ssl=true,password=YourPrimaryKey");            IDatabase cache = connection.GetDatabase();            // Perform cache operations using the cache object...            // Simple put of integral data types into the cache            cache.StringSet("key1", "value");            cache.StringSet("key2", 25);            // Simple get of data types from the cache            string key1 = cache.StringGet("key1");            Console.WriteLine(key1);            int key2 = (int)cache.StringGet("key2");            Console.WriteLine(key2);            Console.Read();        }






PrimaryKey在這裡看:



將代碼中的"your_domain"替換為你的DNS,password替換為你的PrimaryKey

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

Windows Azure 系列-- Azure Redis Cache的配置和使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.