Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 26AEA11588 for ; Tue, 6 May 2014 23:19:59 +0000 (UTC) Received: (qmail 92350 invoked by uid 500); 6 May 2014 23:19:55 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 92273 invoked by uid 500); 6 May 2014 23:19:54 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 92265 invoked by uid 99); 6 May 2014 23:19:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2014 23:19:54 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of tyler@datastax.com designates 209.85.217.181 as permitted sender) Received: from [209.85.217.181] (HELO mail-lb0-f181.google.com) (209.85.217.181) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2014 23:19:50 +0000 Received: by mail-lb0-f181.google.com with SMTP id u14so235490lbd.26 for ; Tue, 06 May 2014 16:19:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=kbKxfgrZ5eynSb6Nsz73acBpP8BQXpt1X69tum0K1ns=; b=OdOyuLAQm499jrDidQmpAm0OB+mQHz3neA7JFezEZ0u9ekyE0WMa4zceYBBwIvhx/H NOoaIWEMMqIzO6tedcgaIQ9hYuj9clU1qtHEmWmv7/6bdnEMTbL2dsxTIasoACCew1oN P7dd9sCwvoTRj3D6O6RsZ3VtiV/QoUq0JYwZ/Tt3vM3g6kemMjPBRrYaOadgEdvXnukD OvciIyWbpfyK5v0sfjXt44gJMJfCqNnHMkDilo5U6rtNd6kjzNhSUuekJPNDwh/8ItKc PQrqM9F8RCTB+XLi2IY+9Mxe1Gkavs2lqYCS2O14mjXdxjr6PKBagABuv0fewWZwVgOd qQjA== X-Gm-Message-State: ALoCoQk4A04VxzCF8DpKzneD8awuRwEmZ/O0IgQoOsKj/aAKThJViNh9MfvZyqw1Potoh4qDU7Fp X-Received: by 10.112.137.5 with SMTP id qe5mr35525636lbb.16.1399418367059; Tue, 06 May 2014 16:19:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.21.132 with HTTP; Tue, 6 May 2014 16:19:06 -0700 (PDT) In-Reply-To: References: From: Tyler Hobbs Date: Tue, 6 May 2014 18:19:06 -0500 Message-ID: Subject: Re: Avoiding email duplicates when registering users To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=089e0115fd3caa3f0d04f8c37a48 X-Virus-Checked: Checked by ClamAV on apache.org --089e0115fd3caa3f0d04f8c37a48 Content-Type: text/plain; charset=UTF-8 On Mon, May 5, 2014 at 10:27 AM, Ignacio Martin wrote: > > When a user registers, the server generates a UUID and performs an INSERT > ... IF NOT EXISTS into the email_to_UUID table. Immediately after, perform > a SELECT from the same table and see if the read UUID is the same that the > one we just generated. If it is, we are allowed to INSERT the data in the > user table, knowing that no other will be doing it. > INSERT ... IF NOT EXISTS is the correct thing to do here, but you don't need to SELECT afterwards. If the row does exist, the query results will show that the insert was not applied and the existing row will be returned. -- Tyler Hobbs DataStax --089e0115fd3caa3f0d04f8c37a48 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On Mon, May 5, 2014 at 10:27 AM, Ignacio Martin <natx.mc@gmail.com>= wrote:

When a user registers, t= he server generates a UUID and performs an INSERT ... IF NOT EXISTS into th= e email_to_UUID table. Immediately after, perform a SELECT from the same ta= ble and see if the read UUID is the same that the one we just generated. If= it is, we are allowed to INSERT the data in the user table, knowing that n= o other will be doing it.

INSERT ... IF NOT EXISTS is the correct t= hing to do here, but you don't need to SELECT afterwards.=C2=A0 If the = row does exist, the query results will show that the insert was not applied= and the existing row will be returned.


--
Tyler Hobbs
DataStax
--089e0115fd3caa3f0d04f8c37a48--