Transformers‎ > ‎


Derquinse Bocas provides a caching transformer based on the cache functionality provided by the Google Guava project.

A Bocas cache is configured using a CachingBocasBuilder, which is instantiated using the BocasServices.cache() method. The configurable parameters are:
  • Expiration time: measured from entity creation or last access.
  • Maximum number of entries (size).
  • Maximum number of bytes of the the values (weight).
Please note that size and weight cannot be set simultaneously.

The provided cache can store the cached value on the heap (backed by loaded values) or on off-heap memory, using direct values. This second option is recommeded for caches that may grow to a considerable size, as it sets less pressure on the garbage collector. However, take your off-heap caches into account when sizing the heap and planning the memory distribution in your machine.

Two examples are shown below, the first with an on-heap cache with a maximum of 1000 entries and 30 seconds of expiration time, and the second an off-heap cache with 512MB of maximum weight. In both cases, the bocas variable holds an existing repository.
The gadget spec URL could not be found
The CachingBocas interface extends the Bocas interface providing access to cache statistics.