Hi All,
I am developing a concurrent application in Ruby, that make use of a
shared data space that will be much easier to implement over CouchDB
than over an RDBMS. I was playing around with Couch Potato and I find it
to be almost perfect for my needs, except for one, but very critical,
conflict issue. I wonder if you could advise me on the best way to
handle this.
In principle, I need my applications to use a function similar to this one:
def foa(index)
keyhash = CouchPotato.database.load_document "keyhash_id"
if (keyhash[index].isnil?)
keyhash[index] = keyhash.size
CouchPotato.database.save_document keyhash
end
return (keyhash[index])
end
The problem is that if I have to applications calling the function
concurrently, it might end up with a conflict, and then the document in
the database will have for example keyhash["abcd"] =5 /or
/keyhsah["efgh"] = 5 instead of keyhash["abcd"] = 5 /and/
keyhash["efgh"] = 6 (this is a rather classical concurrency conflict
problem so I suppose you understand what I mean...)
I suppose I could build some checkout/checkin mechanism that will
involve more documents and communication with the DB server, but again,
I rather use something which is a common practice, so I'd be happy to
get some advice.
Many thanks,
Oren Shani