UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'E3wH6CqD2voSthTbdDF73dUAtDj5NLRknqI2yhpyCzI=' 
WHERE 
  key_id = 'a583596fed8fa9e29dc2c5ce740762e50918007bbba41251fdf05a603076da23' 
  AND (
    token = 'E3wH6CqD2voSthTbdDF73dUAtDj5NLRknqI2yhpyCzI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035