page_type | languages | name | description | products | |||
---|---|---|---|---|---|---|---|
sample |
|
Quickstart: Use Azure Cache for Redis in Java with Redisson Redis client and JCache |
Learn how to incorporate Azure Cache for Redis into a Java app using the Redisson Redis client and JCache. |
|
This sample show you how to incorporate Azure Cache for Redis into a Java app using the Redisson Redis client and JCache.
- Azure subscription - create one for free
- Azure Cache for Redis cache - create one
- Apache Maven
Depending on your operating system, add environment variables for your cache's Host name and Primary access key. Open a command prompt, or a terminal window, and set up the following values:
set REDIS_CACHE_HOSTNAME=<YOUR_HOST_NAME>.redis.cache.windows.net
set REDIS_CACHE_KEY=<YOUR_PRIMARY_ACCESS_KEY>
export REDIS_CACHE_HOSTNAME=<YOUR_HOST_NAME>.redis.cache.windows.net
export REDIS_CACHE_KEY=<YOUR_PRIMARY_ACCESS_KEY>
Replace the placeholders with the following values:
<YOUR_HOST_NAME>
: The DNS host name, obtained from the Properties section of your Azure Cache for Redis resource in the Azure portal.<YOUR_PRIMARY_ACCESS_KEY>
: The primary access key, obtained from the Access keys section of your Azure Cache for Redis resource in the Azure portal.
Download the sample code to your development PC.
Change directories to the folder containing this sample.
Execute the following Maven command to build and run the app:
mvn compile exec:java -D exec.mainClass=example.demo.App