Azure Cache for Redis 範例Azure Cache for Redis samples

本主題提供「Azure Redis 快取」範例清單,其中涵蓋下列這類案例:連線至快取、對快取進行資料讀取和寫入,以及使用 ASP.NET「Azure Redis 快取」提供者。This topic provides a list of Azure Cache for Redis samples, covering scenarios such as connecting to a cache, reading and writing data to and from a cache, and using the ASP.NET Azure Cache for Redis providers. 有些範例是可下載的專案,有些則提供逐步指導並包括程式碼片段,但沒有可下載專案的連結。Some of the samples are downloadable projects, and some provide step-by-step guidance and include code snippets but do not link to a downloadable project.

Hello World 範例Hello world samples

本節中的範例說明一些基本概念,包括連線至「Azure Redis 快取」執行個體,以及使用各種語言和 Redis 用戶端對快取進行資料的讀取和寫入。The samples in this section show the basics of connecting to an Azure Cache for Redis instance and reading and writing data to the cache using a variety of languages and Redis clients.

Hello world 範例示範如何使用 StackExchange.Redis .NET 用戶端來執行各種快取作業。The Hello world sample shows how to perform various cache operations using the StackExchange.Redis .NET client.

此範例示範如何:This sample shows how to:

  • 使用各種連線選項Use various connection options
  • 使用同步和非同步作業在快取中讀取和寫入物件Read and write objects to and from the cache using synchronous and asynchronous operations
  • 使用 Redis MGET/MSET 命令來傳回所指定金鑰的值Use Redis MGET/MSET commands to return values of specified keys
  • 執行 Redis 交易作業Perform Redis transactional operations
  • 使用 Redis 清單和已排序的集合Work with Redis lists and sorted sets
  • 使用 JsonConvert 序列化程式儲存 .NET 物件Store .NET objects using JsonConvert serializers
  • 使用 Redis 集合來實作標記Use Redis sets to implement tagging
  • 使用 Redis 叢集Work with Redis Cluster

如需詳細資訊,請參閱 GitHub 上的 StackExchange.Redis (英文) 文件,如需更多使用案例,則請參閱 StackExchange.Redis.Tests (英文) 單元測試。For more information, see the StackExchange.Redis documentation on GitHub, and for more usage scenarios see the StackExchange.Redis.Tests unit tests.

如何搭配使用 Azure Redis 快取與 Python 說明如何使用 Python 和 redis-py 用戶端來開始運用「Azure Redis 快取」。How to use Azure Cache for Redis with Python shows how to get started with Azure Cache for Redis using Python and the redis-py client.

使用快取中的 .NET 物件 說明一種將 .NET 物件序列化的方式,以便您能夠對「Azure Redis 快取」執行個體讀取和寫入這些物件。Work with .NET objects in the cache shows you one way to serialize .NET objects so you can write them to and read them from an Azure Cache for Redis instance.

使用 Azure Redis 快取作為 ASP.NET SignalR 的向外延展後擋板Use Azure Cache for Redis as a Scale out Backplane for ASP.NET SignalR

使用 Azure Redis 快取作為 ASP.NET SignalR 的向外延展後擋板範例示範如何使用「Azure Redis 快取」作為 SignalR 後擋板。The Use Azure Cache for Redis as a Scale out Backplane for ASP.NET SignalR sample demonstrates how you can use Azure Cache for Redis as a SignalR backplane. 如需後擋板的詳細資訊,請參閱 使用 Redis 的 SignalR 向外延展For more information about backplane, see SignalR Scaleout with Redis.

Azure Redis 快取客戶查詢範例Azure Cache for Redis customer query sample

本範例示範如何比較從快取中存取資料與從持續性儲存體中存取資料之間的效能。This sample demonstrates compares performance between accessing data from a cache and accessing data from persistence storage. 此範例有兩個專案。This sample has two projects.

ASP.NET 工作階段狀態和輸出快取ASP.NET Session State and Output Caching

使用 Azure Redis 快取來儲存 ASP.NET SessionState 和 OutputCache 範例示範如何使用「Azure Redis 快取」,藉由適用於 Redis 的 SessionState 和 OutputCache 提供者來儲存 ASP.NET「工作階段」和「輸出快取」。The Use Azure Cache for Redis to store ASP.NET SessionState and OutputCache sample demonstrates how you to use Azure Cache for Redis to store ASP.NET Session and Output Cache using the SessionState and OutputCache providers for Redis.

使用 MAML 來管理 Azure Redis 快取Manage Azure Cache for Redis with MAML

使用 Azure 管理庫來管理 Azure Redis 快取範例示範如何使用「Azure 管理庫」來管理 - (建立/更新/刪除) 快取。The Manage Azure Cache for Redis using Azure Management Libraries sample demonstrates how can you use Azure Management Libraries to manage - (Create/ Update/ delete) your Cache.

自訂監視範例Custom monitoring sample

存取 Azure Redis 快取監視資料範例示範如何在「Azure 入口網站」外部存取「Azure Redis 快取」的監視資料。The Access Azure Cache for Redis Monitoring data sample demonstrates how you can access monitoring data for your Azure Cache for Redis outside of the Azure Portal.

使用 PHP 和 Redis 撰寫的 Twitter 風格複製品A Twitter-style clone written using PHP and Redis

Retwis 範例是 Redis Hello World。The Retwis sample is the Redis Hello World. 它是透過 Predis 用戶端使用 Redis 和 PHP 撰寫的最小 Twitter 風格社交網路複製品。It is a minimal Twitter-style social network clone written using Redis and PHP using the Predis client. 原始碼的設計十分簡單,並且同時顯示不同的 Redis 資料結構。The source code is designed to be very simple and at the same time to show different Redis data structures.

頻寬監視器Bandwidth monitor

頻寬監視器 範例可讓您監視用戶端上使用的頻寬。The Bandwidth monitor sample allows you to monitor the bandwidth used on the client. 若要測量頻寬,請在快取用戶端電腦上執行這個範例、呼叫快取,並觀察頻寬監視器範例所報告的頻寬。To measure the bandwidth, run the sample on the cache client machine, make calls to the cache, and observe the bandwidth reported by the bandwidth monitor sample.