Perhaps you could do the db update as an agent action and then the ref
update within the agent action if it is successful - see
http://groups.google.co.za/group/clojure/browse_thread/thread/d645d77a8b51f01/667e833c1ea381d7

Regards, Adrian.

On Fri, Apr 3, 2009 at 11:02 AM, Brian Carper <briancar...@gmail.com> wrote:
>
> Is there a safe way to keep the data in a Clojure ref and the data in
> a table in an external (e.g. mysql) database in sync, given concurrent
> creates/updates/deletes from within Clojure?
>
> I can't do a DB update from within a dosync because of retries.  If I
> send-off an agent for the DB update from within a dosync, it won't
> happen until after the dosync is done, and then if the DB update
> throws an exception, it'll be too late to rollback the ref and they'll
> be out of sync.  If I do the DB update and ref update separately,
> there's the potential for race conditions if things happen in between.
>
> Is manual locking the only way?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to