Prefetch cachewhy use it

I am struggling to figure out what advantage there would be to use prefetch cache. If your cache expires every 15 minutes for instance, then the first invocation of the service with a given set of inputs after 15 minutes will refresh the cache. Is the idea to keep any service that calls the cached service from being delayed? I don’t see that prefetching the cache buys you that much. Or maybe I don’t understand it well enough.

1 Like


Long time no hear. I use prefetch when I need to optimize code in a high-volume/high-transaction environment.

Don’t confust prefetching with caching. Caching will cache the last run if of the flow service. If the given input to the flow service is the same, it will just return the previous results. My issue with caching has been that it returns the entire previous pipeline which overwrites what I have in the current pipeline. I NEVER use caching as a result. Maybe others have had different results.

The prefetch just runs the service at an interval and caches the results. I use it when I am gathering profile-based data to run global services, query for system status, or return static data that is stored elsewhere (besides in a flow).



We have successfully used caching by writing a Java wrapper service so only the specific data is cached.

Caching can work: just use either scoping to restrict it inside a document/record (so you don’t get the whole pipeline getting messed around), or else use it as a transformer.

Ray, great insights (as always). I think there’s a case for using prefetch along with caching as well though. If you do cache a service’s results and they expire in say, 60 minutes, when that service is invoked again it will run and have its results re-cached. If you set up prefetch however, when the cache expires the service will automatically be run again to re-cache its results, without waiting for another invocation.

This may seem of marginal value, but I would think it could provide some benefit in very demanding situations. The problem I see with it is that prefetch would seem to be more valuable for very intensive services. However, these types of services are less likely to be good candidates for caching.

As for the difficulties with caching itself, I couldn’t agree more. In fact, I’m certain I’ve requested a change to the default behavior in the Advantage WishList forum at least once. There are also other threads here (as I’m sure you know) where some have made suggestions for workarounds. Unfortunately, they all require very deliberate coding practices to succeed, and that requires lots of coordination in a moderate-to-large development team.