Avoid race condition on cache/session updates
rewrite with bindVars syntax
improve syntax for on-duplicate-key, and rewrite to bindVars syntax
Merge pull request #244 from drbyte/race-cond

Handle race condition