Using the Cache

TorqueBox provides a built-in caching mechanism using the Infinispan data grid. Infinispan can work in a distributed cluster to replicate storage, but its distributed features are available only when deployed to a WildFly or EAP cluster. In non-clustered mode Infinispan’s cache still offers features such as eviction, expiration, persistence, and transactions that aren’t available in typical caching implementations.

You can easily demonstrate the TorqueBox cache in an IRB session. Run jirb in a terminal and execute the following commands in the new session:

 jruby-9.0.5.0 :001 > require 'torquebox-caching'
 => true
 ...
 jruby-9.0.5.0 :002 > c = TorqueBox::Caching.cache("foo")
 => #<TorqueBox::Caching::Cache:0x7ee3d262 @cache={}, ...

Get Deploying with JRuby 9k now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.