On Mon, Apr 6, 2009 at 12:58 AM, Dex Wood <slash2...@gmail.com> wrote:
>
> 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.

Yes, thanks very much for this tip! I have to admit I didn't (don't)
understand the agent concept. I've been avoiding the subject I guess.
Going to have a look now...


>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to