Want to bring more performance, speed, and scalability to your website? Or scale your sites for real-time services or message passing? Learn how, and get practical real-world tips in this exploration of Redis, part of a series on choosing the right data storage.
Steven Edouard and I (Rami Sayar) show you how to get up and running with Redis, a powerful key-value cache and store. In this tutorial series, you can check out a number of practical and advanced use cases for Redis as cache, queue, and publish/subscribe (pub/sub) tool, look at NoSQL and data structures, see how to create list sets and sorted sets in the cache, and much more. You can watch the course online on Microsoft Virtual Academy.
Level: Beginner to Intermediate.
By the end of this installment, you will:
- Learn about Azure Redis Cache
- Learn how to create a new cache in the Azure portal.
- Learn how to connect to your instance using the CLI.
Azure Redis Cache
Microsoft Azure Redis Cache is based on the popular open source Redis Cache. It gives you access to a secure, dedicated Redis cache, managed by Azure. Any updates or patches to Redis are fully managed by Azure. A cache created using Azure Redis Cache is accessible from any application.
Microsoft Azure Redis Cache is available in two tiers:
- Basic – Single node. Multiple sizes.
- Standard – Two-node Master/Slave. Includes SLA and replication support. Multiple Sizes.
The cache is available in sizes up to 53 GB.
Azure Redis Cache leverages Redis authentication and supports SSL connections to Redis.
Creating a New Cache
- Click the New button on the left bottom corner.
- Select the Data+Storage option in the Create blade and then select the Redis Cache option in the Data + Storage blade.
- Name your new Redis Cache and select the size in the Pricing Tier option. Press create at the bottom when satisfied.
- Go to the Startboard and wait for the new Redis Cache to be created.
Connecting to your Instance with Redis CLI
Obtaining Your Connection Information
Click on the the newly created Redis Cache tile and select 'All Settings', then select Properties:
Save the hostname somewhere we'll need that in a second. Back on the Settings blade click Access Keys option and copy the Primary key:
Finally, we'll disable SSL which is turned on by default. Redis clients may or may not support SSL. For example, the Node.js client doesn't support SSL out of the box but this fork provides an implementation. The Python Redis client has support for SSL.
For the purposes of this tutorial series, we'll turn SSL off:
Connecting to the Redis server
To connect to the Azure Redis instance, you can execute this command:
$ redis-cli -h <redis-cache-name>.redis.cache.windows.net -p 6379 -a <your key>
This command creates a connection to your Azure Redis instance. You can execute any of the commands that you could do against a local Redis instance.