UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'IdRbwh/E63PR0kf9U0GRpjjgwxlIpg1M4a+wXsCPxfA=' 
WHERE 
  key_id = '870581adc240ed0f0c284c6e14a3e06ec938904b5e85fc90ae458033de6f5259' 
  AND (
    token = 'IdRbwh/E63PR0kf9U0GRpjjgwxlIpg1M4a+wXsCPxfA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031