Skip to content

Sharded Jedis Sentinel Pool used to obtain ShardedJedis resources from HA Redis cluster

License

Notifications You must be signed in to change notification settings

turu/sharded-jedis-sentinel-pool

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sharded Jedis Sentinel Pool

Sharded Jedis Sentinel Pool used to obtain ShardedJedis resources from HA Redis cluster

Usage

Functionally this resource pool is a merge of Sentinel Pool and Sharded Pool.

You can create it f.e. like that:

//you need a list of master names as registered at Sentinels
final List<String> masters = Arrays.asList("shard1", "shard2");

//and a list of Sentinels themselves
final Set<String> sentinels = Sets.newHashSet("localhost:26379", "localhost:26380", "localhost:26381");

//the masters host:ports will be automatically resolved against Sentinels and shards initialized
ShardedJedisSentinelPool pool = new ShardedJedisSentinelPool(masters, sentinels, "password");

Once you create a ShardedJedisSentinelPool you can use it the same way as you would before:

try {
    jedis = pool.getResource();
    //(...)
    jedis.set("jestem", "sliczny");
    jedis.get("jestem");
    //(...)
} finally {
    if (jedis != null) pool.returnResource(jedis);
}

//... eventually ...
pool.destroy();

About

Sharded Jedis Sentinel Pool used to obtain ShardedJedis resources from HA Redis cluster

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%