Fixes issue #495 : the cache value can get out of sync with the actual v...

...alue due to a data race