in reply to
'state' variables and unit testing
Note that the equivalent to state vars is my $_cached = ..., not our $_cached = ..., so you are really comparing apples and oranges.
But the problem is really something else: caching a value that depends on another value without taking this dependency into account is a bug, and unit testing simply exposes this bug. If you do the caching via state variables or not is really secondary. (And if the caching does not depend on a different value, then I don't see the problem for unit testing).
Update: I should say that state holds global state (but hey, its name even suggests that it holds state :-), even though access to it isn't global. So it should be used with care.