Caching Configuration

Caching configuration is important if you expect your applications to retrieve same data on frequently.

KonfDB host supports in-memory caching and the caching strategy can be defined under the ‘cache’ node.  Sample configuration for caching is as under

"cache": {
    "enabled": false,
    "mode": "Absolute",
    "duration": 30
  }

enabled

When enabled attribute is set to true, in-memory caching will be active.  This means that not every query to KonfDB will get you the data from the data-store.

Caching must be enabled if you do not have multiple applications updating the data in your data-store.  If most of your operations are going to be read-operations, you can enable caching to true.

mode

Valid Values: Absolute, Sliding

Absolute expiration means it will expire cache after some time period set at the time of activating cache. This will be absolute expiration whether cache will be used or not It will expire the cache. This type of expiration used to cache data which are not frequently changing.

Sliding expiration means It will expire cache after time period at the time of activating cache if any request is not made during this time period. This type of expiration is useful when there are so many data to cache. So It will put those items in the cache which are frequently used in the application. So it will not use unnecessary memory.

duration

duration is the expiry time of the cache in seconds.

The duration (expiry time) should not be too high in value else it will increase the memory consumption of the server hosting KonfDBH (host) and may provide stale data if there are write operations performed on the data-store.