UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'nQ1AY1VgXo+pXmxZEMm+58U/0hwyiUtufcQTGfZxOK8=' 
WHERE 
  key_id = '081e9f078ac213ffa67f63268dac17dce4cf81665b027c66aa263405986be115' 
  AND (
    token = 'nQ1AY1VgXo+pXmxZEMm+58U/0hwyiUtufcQTGfZxOK8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038