Skip to content

Latest commit

 

History

History
27 lines (14 loc) · 1.05 KB

README.md

File metadata and controls

27 lines (14 loc) · 1.05 KB

ElastiCacheRedisLoadBalancer

Summary

Version: 0.0.1
Notes: To be used in a non-sharded redis version.

This simple library provides a list of available read replica's for a given ElastiCache ReplicationGroupId and provides options to load balance against them by randomly selecting a node that you can connect to.

static ReadReplicaBalancer readReplicaBalancer = new ReadReplicaBalancer();

Example: ArrayList endpoints = readReplicaBalancer.getReadReplicaEndpoints(replicationGroupId, elastiCacheClient);

Option 1: Randomly select a node from the available replica's

Example 1: String node = readReplicaBalancer.loadBalance(endpoints);

Option 2: Randomly select a node from the available replica's excluding a node

Example 2: String node = readReplicaBalancer.loadBalance(endpoints, NodetoExclude);

Demo code shows how it can be used with Jedis but any Redis Java Library will work.

The code loops through the library so you can test against it.

Jedis jedis = new Jedis(node, 6379);