in reply to How to test caching?

If modifying foo is not an option, then I would also suggest to do some timing tricks.

But maybe you can modify foo such, that when called in array context, it returns an indicator if the data was retrieved from the cache or not?

# normal use $res = foo($arg); # test use ($res, $cached) = foo($arg);