# Advanced Cache

The Advanced Cache plugin provides the ability to define and configure named caches, which can be used by any Rosetta feature that retrieves caches by name from the CacheManager. For instance, they can then be used to cache different parts of a Data Service multi-request with different caches (e.g. with different ttls) using one of the Views defined in this plugin.

# Dependency Information

<dependency>
  <groupId>com.k-int.rosetta</groupId>
  <artifactId>rosetta-advanced-cache</artifactId>
  <version>3.0.0</version>
</dependency>

# Views

# advanced-cache

The advanced-cache View behaves the same as a data View except that the target model for the View request phase is an AdvancedCacheDataRequest instead of a DataServiceRequest, allowing the cache details to be specified in the cache field.

# Properties

See DataView.


# advanced-cache-multi

The advanced-cache View behaves the same as a data-multi View except that the target model for the View request phase is a map whose values are AdvancedCacheDataRequest objects instead of DataServiceRequest objects, allowing the cache details to be specified independently for each sub-request in their respective cache fields.

# Properties

See DataView.

# Data Structures

# AdvancedCacheDataRequest

# Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "profile": {
      "type": "string"
    },
    "request": {},
    "cache": {
      "type": "object",
      "properties": {
        "key": {
          "description": "The key used to cache the response of this request. If null, the full data service request (excluding the cache parameters) will be used."
        },
        "name": {
          "type": "string",
          "description": "The name of the cache to be used. If null or equal to 'default', then the default data service cache will be used."
        }
      }
    }
  }
}

# Example

{
  "profile": "my-profile",
  "request": {
    "search_string": "John Smith",
    "date_min": "2011",
    "date_max": "2020",
    "offset": 0,
    "limit": 10
  },
  "cache": {
    "key": "John Smith|2011|2020|0|10",
    "name": "my-custom-cache"
  }
}

# Configuration Properties

Each of the following properties is prefixed by the property path rosetta.plugins.advanced-cache.

Property Type Default Description
enabled Boolean false Enables the advanced-cache plugin, which autoconfigures the advanced cache manager and enables the advanced-cache and advanced-cache-multi Views.
caches[].name String null The name of this cache. Used when dereferencing the cache in a advanced-cache or advanced-cache-multi View, for instance.
caches[].allow_null_values Boolean false Whether to accept and convert null values for this cache.
caches[].initial_capacity Integer null Sets the minimum total size for the internal data structures. Providing a large enough estimate at construction time avoids the need for expensive resizing operations later, but setting this value unnecessarily high wastes memory.
caches[].maximum_size Long null Specifies the maximum number of entries the cache may contain.
caches[].expire_after_write Duration null Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, or the most recent replacement of its value.
caches[].expire_after_access Duration null Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, the most recent replacement of its value, or its last access.
caches[].use_scheduler Boolean false Specifies that routine maintenance should be carried out on the cache by the system scheduler. Without using the scheduler, expired entries are only evicted during cache activity.
priority Integer 0 The priority of the advanced cache manager. Cache managers with higher priorities have lower precedence when resolving a cache by name.