Question
· Jan 4, 2023

Caching Strategies in ObjectScript

We have a scenario where an ObjectScript-based production calls a lookup service (SOAP in C#) to get information used in a value-set mapping process. The results can be cached in an IRISTEMP global to prevent a network call for every value, but that can hang around for quite some time on production systems.

The next logical step would seem to be to encapsulate strategies (LRU, MRU, etc.) and eviction code into an ObjectScript class that can be reused (we are not in a position yet to leverage embedded Python).

As mature as the platform is, I can't shake the feeling that I am about to reinvent the wheel here. Community and Doc searches seem to yield nothing that might already implement this kind of behavior save for ECP, and that does not appear to be quite the same use case.

Did I miss the obvious solution to caching with eviction here? We really want to avoid bespoke code when there is a de-facto standard approach for doing something on the IRIS platform.

Thanks in advance for any who take the time to respond!

Cheers,

Jonathan

Product version: IRIS 2021.1
Discussion (2)1
Log in or sign up to continue

Globals are cached in global buffer and you can use that.

  1. Create a new database CACHED with a distinct block size (16, 32, or 64 Kb).
  2. In your global buffer settings, set the global buffer for that block size to be equal to the amount of memory you want to allocate to the cache.
  3. Map cache global into a CACHED database.

This will give you an in-memory LRU cache. If you also follow @Dmitry Maslennikov's suggestion and use PPG, nothing would be persisted. Otherwise you'll need to invalidate the persisted cache manually/by a task.