Work with a cache

When you create the OlpClientSettings instance, an in-memory cache is automatically created with the default capacity of 2 MB. You can set new cache capacity as well as get the current cache capacity and size.

To work with the cache:

  1. Create the OlpClientSettings instance.

    For instructions, see Create platform client settings.

  2. Get the LRU cache instance.

     const cache = settings.cache;
  3. Do one of the following:

    • To get the maximum cache capacity, call the getCapacity method.


      You receive the total amount of memory that can be consumed by the cache in MB.

    • To get the current cache size, call the getSize method.


      You receive the total size of all the objects in the cache in MB.

    • To change the cache capacity, call the setCapacity method with the new capacity in MB.


      If the new capacity is smaller than the current cache size, all items are evicted until the cache shrinks to the specified capacity.

        cache.setCapacity("new cache capacity in MB");

results matching ""

    No results matching ""