Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-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 C7185D358 for ; Mon, 5 Nov 2012 18:47:36 +0000 (UTC) Received: (qmail 5108 invoked by uid 500); 5 Nov 2012 18:47:35 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 5072 invoked by uid 500); 5 Nov 2012 18:47:35 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 5064 invoked by uid 99); 5 Nov 2012 18:47:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2012 18:47:35 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jens@couchbase.com designates 206.225.164.30 as permitted sender) Received: from [206.225.164.30] (HELO EXHUB020-3.exch020.serverdata.net) (206.225.164.30) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2012 18:47:27 +0000 Received: from EXVMBX020-1.exch020.serverdata.net ([169.254.4.103]) by EXHUB020-3.exch020.serverdata.net ([206.225.164.30]) with mapi; Mon, 5 Nov 2012 10:47:05 -0800 From: Jens Alfke To: "user@couchdb.apache.org" Date: Mon, 5 Nov 2012 10:47:06 -0800 Subject: Re: Exist test? Thread-Topic: Exist test? Thread-Index: Ac27hfOMzHV/eVTET1eXWOL3rOitNg== Message-ID: <9D607BF7-197D-47C0-BCF8-3D225405C6CE@couchbase.com> References: <99EA19FD-5ED6-4EDA-B538-2D78DCE47DFF@charter.net> In-Reply-To: <99EA19FD-5ED6-4EDA-B538-2D78DCE47DFF@charter.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org On Nov 5, 2012, at 10:22 AM, Kevin Burton wrote: > I am calling CreateDocument() but I suspect that testing if the= document exists first may perform better in the long run. I am using Dream= Seat for my driver but I suspect other drivers have a similar "test". My pr= oblem is that I don't know what to test for and I am unfamiliar with the av= ailable methods. Any one successfully use such a pattern (preferably with D= reamSeat) that tests for existence then creates if the document doesn't exi= st? Keep in mind I don't initially have an id. Thank you. I don=92t know anything about that particular API, but in general, check-th= en-create doesn=92t work well in a concurrent environment. It=92s prone to = race conditions where something else creates the resource in between your c= heck call and your create call. (The canonical example is checking whether = a file exists, then creating the file, which is a classic old security hole= in privileged Unix tools.) =97Jens=