If you want to do I/O from a transaction, just use an agent to do the I/O. Since the agent is only sent off at commit, you don't have to worry about retries. This doesn't answer your questions about idempotent I/O, but I think it is a strategy that you can use.
On Apr 5, 2:11 pm, Hugh Winkler <hwink...@gmail.com> wrote: > Hi all, > > Fromhttp://clojure.org/refs: "I/O and other activities with > side-effects should be avoided in transactions, since transactions > will be retried. The io! macro can be used to prevent the use of an > impure function in a transaction." > > Isn't it OK to do I/O in a transaction as long as doing the operation > multiple times has the same effect as doing it once (i.e. it's > idempotent)? > > Isn't it also OK to read data in a transaction, in many circumstances? > Even if retrying the reads results in a different end state, that's OK > for lots of systems. Example: couldn't I safely read a stock price > from a ticker stream within a transaction, if the purpose was only to > have a cached value from sometime in the last 5 minutes? > > (I imagine there are performance considerations. Retrying some I/O > operations could be expensive. Right now, I'm concerned with the > logic, not the performance, but if you know something about the > performance implications, please jump in). > > Just hoping someone can straighten me out if I'm wrong... I'd like to > remove some io! macros from my code! > > Thanks, > Hugh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---