This article provides answers to common questions about how to develop for Azure Cache for Redis.
How can I get started with Azure Cache for Redis?There are several ways you can get started with Azure Cache for Redis.
If you don't already have an Azure account, you can:
StackExchange.Redis has many options. This section talks about some of the common settings. For more detailed information about StackExchange.Redis options, see StackExchange.Redis configuration.
ConfigurationOptions Description Recommendation AbortOnConnectFail When set to true, the connection can't reconnect after a network failure. Set to false and let StackExchange.Redis reconnect automatically. ConnectRetry The number of times to repeat connection attempts during initial connect. See the following notes for guidance. ConnectTimeout Timeout in ms for connect operations. See the following notes for guidance.Usually the default values of the client are sufficient. You can fine-tune the options based on your workload.
RetriesAbortOnConnectFail
to false and let StackExchange.Redis reconnect for you.ConnectionMultiplexer
instance rather than creating a new connection for each request.ConnectionMultiplexer.ClientName
property to an app instance unique name for diagnostic purposes.ConnectionMultiplexer
instances for custom workloads.
ClientName
property on each multiplexer to help with diagnostics.ConnectionMultiplexer
.One of the great things about Redis is that there are many clients supporting many different development languages. For a current list of clients, see Redis clients. For tutorials that cover several different languages and clients, see How to use Azure Cache for Redis.
Get cache host name, port, and access keys from the Azure portalTo connect to your Azure Redis cache, the cache client needs the cache host name, ports, and keys. Some clients might refer to these items by slightly different names. Follow these instructions to get the cache host name, ports, and keys from the Azure portal.
Get the host name from the cache Overview page. The host name is of the form <cachename>.redis.cache.windows.net
.
Select the link next to Ports to get the ports. Enterprise and Enterprise Flash tier caches use port 10000
. Basic, Standard, and Premium tier caches use either port 6380
for Transport Layer Security (TLS) connections or port 6379
for non-TLS connections.
To get the access keys, select Show access keys.
The CacheKeys pane displays the keys.
You can also select Authentication under Settings in the left navigation menu, and then select the Access keys tab.
There's no local emulator for Azure Cache for Redis. You can, however, run a copy of community Redis on your local machine and connect to it to get a similar experience to a local cache emulator, as shown in the following example:
private static Lazy<ConnectionMultiplexer>
lazyConnection = new Lazy<ConnectionMultiplexer> (() =>
{
// Connect to a locally running instance of Redis to simulate
// a local cache emulator experience.
return ConnectionMultiplexer.Connect("127.0.0.1:6379");
});
public static ConnectionMultiplexer Connection
{
get
{
return lazyConnection.Value;
}
}
Redis runs natively on Linux, but you can also use Windows Subsystem for Linux to run Redis on a windows machine. For more information, see Install Redis on Windows You can optionally configure a redis.conf file to more closely match the default cache settings for your online Azure Cache for Redis if you want.
How can I run Redis commands?You can use any of the commands listed at Redis commands except for the commands listed at Redis commands not supported in Azure Cache for Redis. You have several options to run Redis commands.
If you have a Standard or Premium cache, you can run Redis commands using the Redis Console. The Redis console provides a secure way to run Redis commands in the Azure portal.
You can also use the Redis command-line tools. To use them, see Use the Redis command-line tool with Azure Cache for Redis
Why doesn't Azure Cache for Redis have an MSDN class library reference?Microsoft Azure Cache for Redis is based on the popular open-source in-memory data store, Redis. You can use a wide variety of Redis clients for many programming languages. Each client has its own API that makes calls to the Azure Cache for Redis instance using Redis commands.
Because each client is different, you can't find one centralized class reference on MSDN. Each client maintains its own reference documentation. Besides the reference documentation, there are several tutorials showing how to get started with Azure Cache for Redis using different languages and cache clients. To access these tutorials, see How to use Azure Cache for Redis and its sibling articles in the table of contents.
Can I use Azure Cache for Redis as a PHP session cache?Yes, to use Azure Cache for Redis as a PHP session cache, specify the connection string to your Azure Cache for Redis instance in session.save_path
.
Important
When using Azure Cache for Redis as a PHP session cache, you must URL encode the security key used to connect to the cache, as shown in the following example:
session.save_path = "tcp://mycache.redis.cache.windows.net:6379?auth=<url encoded primary or secondary key here>";
If the key isn't URL encoded, you might receive an exception with a message like: Failed to parse session.save_path
For more information about using Azure Cache for Redis as a PHP session cache with the PhpRedis client, see PHP Session handler.
What are Redis databases?Redis Databases are just a logical separation of data within the same Redis instance. The cache memory is shared between all the databases and actual memory consumption of a given database depends on the keys/values stored in that database. For example, a C6 cache has 53 GB of memory, and a P5 has 120 GB. You can choose to put all 53 GB / 120 GB into one database or you can split it up between multiple databases.
Note
When using a Premium Azure Cache for Redis with clustering enabled, only database 0 is available. This limitation is an intrinsic Redis limitation and isn't specific to Azure Cache for Redis.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4