UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'bbHJV/vZE5fNawoaYuH1n0Dx64OptTaecibeoVFuqLM=' 
WHERE 
  key_id = '0d8745bfd71c014e8d1197796b299113c6a0f46427475d031052766af57283da' 
  AND (
    token = 'bbHJV/vZE5fNawoaYuH1n0Dx64OptTaecibeoVFuqLM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031