UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Hy4K0FnMNqZ6sVmuyvXYCo0yD/WiBjOyDdxuLTuYXb0=' 
WHERE 
  key_id = '8d6049c1a433a56a5dd99a91966d1a0437a0e205d5204908397de1a787562904' 
  AND (
    token = 'Hy4K0FnMNqZ6sVmuyvXYCo0yD/WiBjOyDdxuLTuYXb0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028