On 04/04/2009, at 1:52 AM, Andrius Juozapaitis wrote:
Spring allows you to create application-wide singletons, one of which
could be the jcouchdb Database object.
In order to keep the write serialization more or less transparent to
the application developer, I guess
1) I'd write an aspect on top of that bean, that would proxy the
update/delete related operations, adding the identity of object
operated on to an active object list (exact data structure might
vary).
2) Another aspect would handle the bulk insert method; it would check
if any of the objects being inserted/updated are already in the active
objects list, and if not, add all the inserted object ids to the
active object list before update, and removing them afterwards.
3) Operations (update/delete) that affect objects already in active
object list would simply throw an exception without even hitting
couchdb.
Then just serialize the access to that active object list. What do
you think?
You would still get conflict on update unless you serialise all access
and check the existing rev of all intended updates before committing.
I'm not sure the active list buys you much - you also need to deal
with replication updating the db.
Antony Blakey
--------------------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787
Man will never be free until the last king is strangled with the
entrails of the last priest.
-- Denis Diderot