Over a million developers have joined DZone.

Redis Users Rejoice! The JCache API Is Here

If you've been waiting for Redisson's JCache API implementation, then wait no more.

· Java Zone

Navigate the Maze of the End-User Experience and pick up this APM Essential guide, brought to you in partnership with CA Technologies

The JCache API implementation for Redis has been expected by Java community since its publication. Finally, the day has come. The Redisson team now proudly presents to you our JCache API (JSR-107) implementation for Redis, an implementation based on the Redisson framework.

Let's get started with a few configuration examples. Redisson supports two configuration formats — JSON and YAML. If a configuration instance is not defined at runtime, then Redisson will look for /redisson-jcache.json or /redisson-jcache.yaml in the classpath.

MutableConfiguration<String, String> config = new MutableConfiguration<>();

CacheManager manager = Caching.getCachingProvider().getCacheManager();
Cache<String, String> cache = manager.createCache("namedCache", config);

The configuration can be defined manually and loaded from literally anywhere, thanks to the URI object.

MutableConfiguration<String, String> config = new MutableConfiguration<>();

// json config
URI redissonConfigUri = getClass().getResource("redisson-jcache.json").toURI();
// or yaml config
URI redissonConfigUri = getClass().getResource("redisson-jcache.yaml").toURI();

CacheManager manager = Caching.getCachingProvider().getCacheManager(redissonConfigUri, null);
Cache<String, String> cache = manager.createCache("namedCache", config);


It's also worth mentioning that Redisson supports all available Redis configurations:

AWS Elasticache Replication

Automatic Redis master node change discovery.
Config file examples

AWS Elasticache Cluster

Automatic Redis master nodes change discovery
Automatic Redis (master/slave) nodes topology discovery/update
Automatic Redis cluster slots change discovery
Config file examples

Cluster

Automatic Redis master nodes change discovery
Automatic Redis (master/slave) nodes topology discovery/update
Automatic Redis cluster slots change discovery
Config files examples

Sentinel

Automatic Redis master node change discovery
Automatic Redis (master/slave/sentinel) nodes topology discovery/update
Config file examples

Master/Slave

Config file examples

Single

Config file examples

Data Serialization

Data serialization has always been an important part of any framework that works with Redis. Redisson has provided a few good data codecs to choose from:

  1. Jackson JSON
  2. Avro
  3. Smile
  4. CBOR
  5. MsgPack
  6. Kryo
  7. FST
  8. LZ4
  9. Snappy
  10. JDK Serialization

Conclusions

If you one of those who has been waiting for Redis based JCache API (JSR-107) implementation, then wait no more. Enjoy Redisson!

Thrive in the application economy with an APM model that is strategic. Be E.P.I.C. with CA APM.  Brought to you in partnership with CA Technologies.

Topics:
redis ,java ,jcache ,api

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}