My api depends on some programs that are expensive to start up for each call. I am trying to inject a cache that contains the cached objects wrapping the programs so they can be reused without killing executables between calls to my api.
Before trying to use a cache each call would start up their own instance of a program and run, which is important as it is wrapped COBOL programs with static variables.
My problem is that I'm not sure how I use the cache such that the cached objects are exclusive while used by a call. I want another program to be started up if another call has already hit the cache with the same key and is still using that value. Would be great if I can somehow build up a pool as needed for each program, some a used a lot, some rarely.