Search code examples
redisjedis

Jedis pool for BinaryJedisCluster


BinaryJedis is not thread-safe but it can be derived from JedisPool getResource which returns a type Jedis. Is BinaryJedisCluster thread-safe? If not, is there a connection pool which returns a type compatible with BinaryJedisCluster? I want to use BinaryJedisCluster in a multi-threaded environment


Solution

  • BinaryJedisCluster is thread-safe. It internally uses JedisPool.

    Elaborately,

    • BinaryJedisCluster uses JedisClusterConnectionHandler
    • JedisClusterConnectionHandler uses JedisClusterInfoCache
    • JedisClusterInfoCache uses JedisPool

    So, BinaryJedisCluster is as safe as JedisPool.