text: How to Use Azure Redis Cache
  This guide shows you how to get started using Azure is available in the following tiers:
  - Basic – Single node. Multiple sizes up to 53 GB.
  - Standard – Two-node Primary/Replica. Multiple sizes up to 53 GB. 99.9% SLA.
  - Premium – Two-node Primary/Replica with up to 10 shards. Multiple sizes from 6 GB to 530 GB (contact us for more). All Standard tier features and more including support for Redis cluster, Redis persistence, and Azure Virtual Network. 99.9% SLA.
  Each tier differs in terms of features and pricing. For information on pricing, see Cache Pricing Details.
  This guide shows you how to use the StackExchange.Redis client using C# code. The scenarios covered include creating and configuring a cache, configuring cache clients, and adding and removing objects from the cache. For more information on using Azure Redis Cache, refer to the Next Steps section. For a step-by-step tutorial of building an ASP.NET MVC web app with Redis Cache, see How to create a Web App with Redis Cache.
  Getting started with Azure Redis Cache is easy. To get started, you provision and configure a cache. Next, you configure the cache clients so they can access the cache. Once the cache clients are configured, you can begin working with them.
  Create a cache
  To create a cache, first sign in to the Azure Portal, and click New, Data + Storage, Redis Cache.
  Note:
  If you don't have an Azure account, you can Open an Azure account for free in just a couple of minutes.
  Note:
  In addition to creating caches in the Azure Portal, you can also create them using ARM templates, PowerShell, or Azure CLI.
  - To create a cache using ARM.
  Once the new cache options are configured, click Create. It can take a few minutes for the cache to be created. To check the status, you can monitor the progress on the startboard. After the cache has been created, your new cache has a Running status and is ready for use with default settings.
  To access your cache after it's created
  Caches can be accessed in the Azure Portal using the Browse blade.
  Click Browse > Redis Caches to view your caches. If you have recently browsed to a Redis Cache, you can click Redis Caches directly from the list without clicking Browse.
  Select the desired cache to view the properties for that cache.
  Click Settings or All settings to view and configure your cache.
  For more information about configuring your cache, see How to configure Azure Redis Cache.
  Configure the cache clients
  .NET applications can use the StackExchange.Redis cache client, which can be configured in Visual Studio using a NuGet package that simplifies the configuration of cache client applications.
  Note:.
  Type StackExchange.Redis or StackExchange.Redis.StrongName into the search text box, select the desired version from the results, and click Install.
  Note:.
  Note:
  If you have previously configured your project to use StackExchange.Redis, you can check for updates to the package from the NuGet Package Manager. To check for and install updated versions of the StackExchange.Redis NuGet package, click Updates in the the NuGet Package Manager window. If an update to the StackExchange.Redis NuGet package is available, you can update your project to use the updated version.
  Once your client project is configured for caching, you can use the techniques described in the following sections for working with your cache.
  Working with Caches
  The steps in this section describe how to perform common tasks with Cache.
  Connect to the cache
  In order to programmatically work with a cache, you need a reference to the cache. Add the following to the top of any file from which you want to use the StackExchange.Redis client to access an Azure Redis Cache.
  using StackExchange.Redis;
  The connection to the Azure Redis Cache is managed by the
  ConnectionMultiplexer class. This class and key like the following example. Use the key generated from the Azure Portal as the password parameter.
  ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("contoso5.redis.cache.windows.net,abortConnect=false,ssl=true,password=...");
  Important:
  Warning: Never store credentials in source code. To keep this sample simple, I’m showing them in the source code. See How Application Strings and Connection Strings Work for information on how to store credentials.
  If you don't want to use SSL, either set
  ssl=false or omit the
  ssl parameter.
  Note:
  The non-SSL port is disabled by default for new caches. For instructions on enabling the non-SSL port, see the Access Ports..
  One approach to sharing a
  ConnectionMultiplexer instance in your application is to have a static property that returns a connected instance, similar to the following example. This provides a thread-safe way to initialize only a single connected
  ConnectionMultiplexer instance. In these examples
  abortConnect is set to false, which means that the call will succeed even if a connection to the Azure Redis Cache is not established. One key feature of
  ConnectionMultiplexer is that it will automatically restore connectivity to the cache once the network issue or other causes are resolved.
  private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() => { return ConnectionMultiplexer.Connect("contoso5.redis.cache.windows.net,abortConnect=false,ssl=true,password=..."); }); public static ConnectionMultiplexer Connection { get { return lazyConnection.Value; } }
  For more information on advanced connection configuration options, see StackExchange.Redis configuration model.
  To connect to an Azure Redis Cache instance, cache clients need the host name, ports, and keys of the cache. Some clients may refer to these items by slightly different names. To retrieve these items, browse to your cache in the Azure portal and click Settings or All settings.
  Host name and ports
  To access the host name and ports click Properties.
  Access keys
  To retrieve the access keys, click Access keys.
  Once the connection is established, return a reference to the redis cache database by calling the
  ConnectionMultiplexer.GetDatabase method. The object returned from the
  GetDatabase method is a lightweight pass-through object and does not need to be stored.
  // Connection refers to a property that returns a ConnectionMultiplexer // as shown in the previous example. 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"); int key2 = (int)cache.StringGet("key2");
  Now that you know how to connect to an Azure Redis Cache instance and return a reference to the cache database, let's take a look at working with the cache.
  Add and retrieve objects from the cache
  Items can be stored in and retrieved from a cache by using the
  StringSet and
  StringGet methods.
  // If key1 exists, it is overwritten. cache.StringSet("key1", "value1"); string value = cache.StringGet("key1");
  Redis stores most data as Redis strings, but these strings can contain many types of data, including serialized binary data, which can be used when storing .NET objects in the cache.
  When calling
  StringGet, if the object exists, it is returned, and if it does not,
  null is returned. In this case you can retrieve the value from the desired data source and store it in the cache for subsequent use. This is known as the cache-aside pattern.));
  Work with .NET objects in the cache
  Azure Redis Cache can cache .NET objects as well as primitive data types, but before a .NET object can be cached it must be serialized. This is the responsibility of the application developer, and gives the developer flexibility in the choice of the serializer.
  One simple way to serialize objects is to use the
  JsonConvert serialization methods in Newtonsoft.Json.NET and serialize to and from JSON. The following example shows a get and set using an
  Employee object instance.
  class Employee { public int Id { get; set; } public string Name { get; set; } public Employee(int EmployeeId, string Name) { this.Id = EmployeeId; this.Name = Name; } } // Store to cache cache.StringSet("e25", JsonConvert.SerializeObject(new Employee(25, "Clayton Gragg"))); // Retrieve from cache Employee e25 = JsonConvert.DeserializeObject<Employee>(cache.StringGet("e25"));
  Next Steps
  Now that you've learned the basics, follow these links to learn more about Azure Redis Cache.
  - Enable cache diagnostics so you can monitor the health of your cache. You can view the metrics in the Azure Portal and you can also download and review them using the tools of your choice.
  - Azure Redis Cache can be accessed from many Redis clients and development languages. For more information, see.
  - Azure Redis Cache can also be used with services such as Redsmin. For more information, see How to retrieve an Azure Redis connection string and use it with Redsmin.
  - See the redis documentation and read about redis data types and a fifteen minute introduction to Redis data types.