UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'poK7m40XQjj6LYq+s5TIbb8130K+NeArRnq2+4nXtfY=' 
WHERE 
  key_id = '56874854e4cf2c07a920d7ef4364506a974e9281463288ae930f4db9e5a9e454' 
  AND (
    token = 'poK7m40XQjj6LYq+s5TIbb8130K+NeArRnq2+4nXtfY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032