The cache may have side effects because the code in #4 and #5 is not always executed when a client calls #3.
Could you please review carefully or alternatively change the algorithm so it becomes usable for large sets of reqs/caps and mods.
Perhaps these large sets should be mocked in the CL testsuite.