Skip to content

Instantly share code, notes, and snippets.

@rustd
Last active August 29, 2015 14:14
Show Gist options
  • Save rustd/33ac3181a6a20f8460f4 to your computer and use it in GitHub Desktop.
Save rustd/33ac3181a6a20f8460f4 to your computer and use it in GitHub Desktop.
Use Jedis client to connet to Azure Redis Cache
package com.mycompany.app;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisShardInfo;
/**
* Make sure your turn on non SSL port in Azure Redis using the Configuration section in the Azure portal.
* Hello world!
* mvn compile
* mvn exec:java
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
JedisShardInfo shardInfo = new JedisShardInfo("enteryourcachename.redis.cache.windows.net", 6379);
shardInfo.setPassword("enteryourpassword");
Jedis jedis = new Jedis(shardInfo);
for(int i=0 ; i < 5 ; i++)
{
jedis.set(""+i, ""+i);
String value = jedis.get(""+i);
System.out.println("value="+ value );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment