I just finished writing a plugin to use Redis as a backing cache for Resteasy served requests.

What’s that mean?

With this plugin, adding @Cache annotations to Resteasy resource classes or methods is all that’s needed to serve requests from a Redis cache instead of performing some expensive operation on a per-request basis.

Responses are cached by URI and content type. Wildcard content types are supported.

That’s all?

Not really. Caveats:

  • @Cache annotations must define a positive maxAge value. This value is used as the time-to-live for each cache entry.
  • The plugin wraps the Jedis client for Redis. You are responsible for providing your own instance of a JedisPool. Protip: Start with a JedisPoolConfig instead of GenericObjectPoolConfig.

Why? Resteasy already uses Infinispan.

I’m not terribly fond of Infinispan. It’s hard to configure. The documentation is poor. In large distributed environments I’ve had JGroups fall apart and leave the cache in a state that required rebooting the cluster.

On the other hand, I love Redis. It’s easy to install, its documentation is great, and it comes with sensible defaults. Plus, its API and data structures are brilliant.

Details?

See the project on Github for instructions, details, and to file any issues.