TRQ-1917. Add some more protections to the caching code in order to avoid a segfault.
Merge branch '4.2-dev' of https://github.com/adaptivecomputing/torque into 4.2-dev