Fixes issue #495 : the cache value can get out of sync with the actual value due to a data race