Using Asset Caching

Overview

Caching is a technique used in software development to improve the performance and efficiency of applications by storing frequently accessed data or computations in a temporary storage area called a cache. The main idea behind caching is to reduce the need to recompute or fetch data from the original source repeatedly, which can be time-consuming and resource-intensive. Instead, the cached data can be quickly retrieved from the cache, resulting in faster response times and reduced system load. Memory caching involves using fast and accessible memory, like RAM, to store frequently used data.

Selection of Caching Method

When generating service source code based on a project and a generator, you have the option of selecting which caching technique will be used when you use the CLI command ol generate to generate the service. The following parameter is available:

--cache, -c

Enable caching with the selected cache solution within the generated project [redis, hazelcast]

Currently, there are two caching options to use:

  • Redis - an open source in-memory data key-value store used as a cache
  • Hazelcast - an open source In-Memory Data Grid used as a cache

To decide which caching method to use, you may want to consult Difference Between Hazelcast vs Redis for more information.

Configuring Asset Caching

You may configure an asset cache using the ol set cache command. This command enables setting which asset fields will be cached and the cache time interval in milliseconds. The command options are:

--asset

The asset name

-cache-key

The cache keys, or asset fields to be cached. For example, "InputField.SubField" "true"

cacheTTL

The cache TTL (time to live), or cache interval in milliseconds.

Configuring Cache Engine Details in the service.yml file

If you have configured caching using the ol generate command, you can then configure the caching engine fields in the service.yml file. For example,

ol:
  license:
    key:
  flow:
    type: RPC
    source-provider: HUB
    hub:
      url: https://api.ol-hub.com
      api-key: 
      project-name: ob-demo
    agent:
      enabled: false
  cache:
    redis:
      client:
        hostname:
        port:
        password:
  rpc:
    cache:
      enabled: true
management:
  endpoints:
    web:
      exposure:
        include:
          - health
          - prometheus

Asset Caching in the UI

In the Ol Hub, you can cache data assets. You have the option of selecting some or all assets to cache as well as the cache latency time interval.

  1. In the Modules screen, click on the icon. A menu appears:
  1. Select the Configure Cache option. The Configure Cache window opens:
  1. Check the Use cache box and enter the cache Time interval (in milliseconds).
  1. Click on Save. The Modules screen reappears:
  1. You may select which assets will be cached by checking the box adjacent to the asset, or you may Select all assets to be cached.
  1. Click the Save button. The cached asset s are indicated by the

icon to the left of the asset.