Dropwizard Redis Bundle

An addon bundle for using the excellent Jedis redis client in Dropwizard applications.

Dependency Info



Add a JedisFactory class:

private JedisFactory redis;

public JedisFactory getJedisFactory() {
    return redis;

public void setJedisFactory(JedisFactory jedisFactory) {
    this.redis = jedisFactory;

Add a JedisBundle classL

public void initialize(Bootstrap<MyConfiguration> bootstrap) {
    // ...
    bootstrap.addBundle(new JedisBundle<AppConfig>() {
        public JedisFactory getJedisFactory(AppConfig configuration) {
            return configuration.getJedisFactory();

This will enable @Context injection of pooled Jedis and JedisPool in resource methods:

public BlogPost getPost(@QueryParam("id") int postId, @Context Jedis jedis) {
  String cachedBlogContent = jedis.get("post-" + postId);
  // do stuff
  // No need to close the connection, it happens automatically.

This will also enable redis health-checking.


For configuration the redis connection, there is JedisFactory:

  # The redis server's address; required.
  endpoint: localhost:6379
  # Auth password for redis server connection.  (default: null)
  password: null
  # The minimum number of idle connections to maintain in the pool.  (default: 0)
  minIdle: 0
  # The maximum number of idle connections allowed in the pool.  (default: 0)
  maxIdle: 0
  # The maximum number of connections allowed in the pool.  (default: 1024)
  maxTotal: 1924
  # Enables SSL connection. (default: false)
  ssl: false
  # The configured timeout (in milliseconds) for redis connections in the connection pool.  (default: 2000)
  timeout: 2000


Please file bug reports and feature requests in GitHub issues.


Copyright © 2014-2020 Benjamin Bader

This library is licensed under the Apache License, Version 2.0.

See http://www.apache.org/licenses/LICENSE-2.0.html or the LICENSE file in this repository for the full license text.