SALES: 1-800-867-1380

Develop in other languages for Azure Redis Cache

Updated: September 23, 2014

.NET Azure Redis Cache applications developed in Visual Studio can use the StackExchange.Redis cache client, but there are also many other Redis clients that can be used to access caches hosted on Azure Redis Cache. While each client is different, they use the same information to connect to Azure Redis Cache. This topic provides an overview of reviewing cache properties and access keys, and how to use this information to connect to Azure Redis Cache.

View cache properties

Caches can be accessed in the Azure Management Portal Preview using the Browse blade.

Azure Redis Cache Browse Blade

Click Caches to view your caches.

Azure Redis Cache Browse Cache List

Select the desired cache to view the properties for that cache.

Azure Redis Cache New Cache Overview

Cache endpoint

Click Properties to view information about your cache, including the cache endpoint and ports.

Azure Redis Cache Properties

The host name takes the format Different clients may refer to this as the endpoint. If your client supports SSL, the SSL Host is * 6379 is the port for non-SSL cache access, and 6380 is the port when using SSL.

Azure Redis Cache supports SSL to secure cache/client applications. Clients that do not support SSL should use the non-SSL port. In most cases, this is the default port if ssl=true is not specified.

Access keys

Click Manage Keys to view or regenerate the access keys for your cache. These keys are used along with the host name and ports from the Properties blade by the clients connecting to your cache.

Azure Redis Cache Manage Keys

Access keys are used to provide access to the cache. Different clients may refer to this as the key or password.

PHP example

One popular client for Redis cache is Predis. This section provides an overview of connecting to your Azure Redis Cache instance using Predis.

For complete documentation and instructions on using the Predis cache client, see the Predis github site.

Include the following items at the top of your PHP file from which you want to access the cache.

require "predis/autoloader.php";
If you already include a file that has these statements, you don’t need to add them again.

To connect to the cache, you can use a function similar to the following example. Use the host name and port from your Azure Redis Cache instance’s Properties blade, and the access key from the Manage keys blade.

function redisLink() {
    static $r = false;

    if ($r) return $r;
     $r = new Predis\Client('tcp://<cache endpoint>:<port>');
     $r->auth("<access key>");

    return $r;

You can call the redisLink function when you connect to the cache to add and retrieve items from the cache.

function loadUserInfo($userid) {
    global $User;

    $r = redisLink();
    $User['id'] = $userid;
    $User['username'] = $r->get("uid:$userid:username");
    return true;

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft