Limit the number of calls to a function by caching the results of execution