Skip to content

Instantly share code, notes, and snippets.

@deepakverma
Last active January 22, 2019 19:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakverma/9aa4dc04ded700603a8ef24eececf5d3 to your computer and use it in GitHub Desktop.
Save deepakverma/9aa4dc04ded700603a8ef24eececf5d3 to your computer and use it in GitHub Desktop.
Jedis Sample
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxTotal" value="10" />
</bean>
<bean id="jedisShardInfo" class="redis.clients.jedis.JedisShardInfo">
        <constructor-arg index="0" value="*.redis.cache.windows.net" />
        <constructor-arg index="1" value="6379" type="int" />
        <property name="password"  value="***"/>
</bean>
try(Jedis jedis = jedisPool.getResource())
{
//pipeline
Pipeline p = jedis.pipelined();
Response<String> pipeIdResponse = p.get("ID");
Response<String> pipeNameResponse = p.get("Name");
p.sync();
String id = pipeIdResponse.get();
String name = pipeNameResponse.get();
System.out.println(id);
System.out.println(name);
}
catch(JedisConnectionException ex)
{
//log.warn("Could not connect to Redis.");
}
catch (JedisException ex)
{
//log.error("Failed to process", e);
}
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxTotal(10);
JedisPool jedisPool = new
JedisPool(poolConfig,"127.0.0.1", 6379); // jedisPool should be re-used and stored statically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment