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
Yeah, that's really, so. Redis has that feature, so you can set a time to live for the value, and it will disappear after that. In IRIS The only way to have something that will be deleted automatically is, Process-Private Globals, but their time to live is tied to the process, and you would still need to clean up if your process is long living.
Globals are cached in global buffer and you can use that.
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.