UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '5+QuOQnJt0lXQM31ctnjX1YaEe7elrfP31MtoCw9QPs=' 
WHERE 
  key_id = '6f30498d8c767b5df0d6862056ad9ca3ec9989234fd066aa3d16bf13321687aa' 
  AND (
    token = '5+QuOQnJt0lXQM31ctnjX1YaEe7elrfP31MtoCw9QPs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00026