Azure Cache for Redis samples

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 samples

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.

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
  • Use Redis MGET/MSET commands to return values of specified keys
  • Perform Redis transactional operations
  • Work with Redis lists and sorted sets
  • Store .NET objects using JsonConvert serializers
  • Use Redis sets to implement tagging
  • Work with Redis Cluster

For more information, see the StackExchange.Redis documentation on GitHub, and for more usage scenarios see the StackExchange.Redis.Tests unit tests.

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.

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.

Use Azure Cache for Redis as a Scale out Backplane for ASP.NET 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. For more information about backplane, see SignalR Scaleout with 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 Session State and Output Caching

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.

Manage Azure Cache for Redis with MAML

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

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.

A Twitter-style clone written using PHP and Redis

The Retwis sample is the Redis Hello World. It is a minimal Twitter-style social network clone written using Redis and PHP using the Predis client. 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.