You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Troy Kruthoff <tk...@gmail.com> on 2009/12/27 21:36:33 UTC

atomic/concurrent update_seq for _changes

I have an app that gets data from a view and then monitors _changes  
for updates.  Currently it:

1)  Gets the update_seq from the database
2)  Gets data from a view
3)  Connects to _changes since updae_seq from #1

I'm assuming I need to handle duplicate data, as the database could of  
been modified since the initial get of the update_seq.

What would be sexy is for couch to include an "x-update-seq" header  
for GET requests.  In my case, this would mean 1 less http request,  
and ensure _changes does not include data already reflected in the view.

Thoughts?

Troy





Re: atomic/concurrent update_seq for _changes

Posted by Chris Anderson <jc...@apache.org>.
On Tue, Dec 29, 2009 at 5:33 PM, Joscha Feth <jo...@feth.com> wrote:
> Joscha Feth wrote:
>
>> I am doing exactly the same in my application and the gap between #1
>> and #2 also worried me - a special header sounds like a feasible
>> solution and I can't see any downside besides the few bytes of
>> overhead in the header for each request.
>
>
> Just for the record: you can create a custom list/show function, which
> adds the header:
>
> "lists": {
> mylist : "function(head, req) { start({\"code\": 200, \"headers\":
> {\"X-Update-Seq\": (\"\"+req.info.update_seq)}}); send(\"whatever\"); }"
> }
>
> One comment: you need to convert the update_seq into a string before
> sending it back via start() - might be a bug.
>

I think a fine way to add this information would be in the JSON view
response body itself, something like:

{"total_rows":1000,"offset":0, "update_seq": 1001, "rows":[
{"id":"1","key":1,"value":null},
...

This patch should be among the more trivial for a new Erlang / CouchDB
author to implement.

I see no reason not to add this feature. If anyone wants to implement,
and has questions or needs help getting started, the dev@ mailing list
is the place.

Cheers,
Chris

> regards,
> Joscha
>
> --
>
>
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: atomic/concurrent update_seq for _changes

Posted by Joscha Feth <jo...@feth.com>.
Joscha Feth wrote:

> I am doing exactly the same in my application and the gap between #1
> and #2 also worried me - a special header sounds like a feasible
> solution and I can't see any downside besides the few bytes of
> overhead in the header for each request.


Just for the record: you can create a custom list/show function, which
adds the header:

"lists": {
mylist : "function(head, req) { start({\"code\": 200, \"headers\":
{\"X-Update-Seq\": (\"\"+req.info.update_seq)}}); send(\"whatever\"); }"
}

One comment: you need to convert the update_seq into a string before
sending it back via start() - might be a bug.

regards,
Joscha

-- 



Re: atomic/concurrent update_seq for _changes

Posted by Joscha Feth <jo...@feth.com>.
On Sun, Dec 27, 2009 at 21:36, Troy Kruthoff <tk...@gmail.com> wrote:
> I have an app that gets data from a view and then monitors _changes for
> updates.  Currently it:
>
> 1)  Gets the update_seq from the database
> 2)  Gets data from a view
> 3)  Connects to _changes since updae_seq from #1

I am doing exactly the same in my application and the gap between #1
and #2 also worried me - a special header sounds like a feasible
solution and I can't see any downside besides the few bytes of
overhead in the header for each request.

regards,
Joscha