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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.