In Rails: How can I turn off caching for a particular activerecord database table?

Posted by pmneve on Stack Overflow See other posts from Stack Overflow or by pmneve
Published on 2010-04-13T01:48:07Z Indexed on 2010/04/13 1:52 UTC
Read the original article Hit count: 316

Filed under:
|
|

I have an associative table (scripts_runs) (has_many, through) that carries a status column ('started', 'ready to parse', 'completed' ). The started and ready to parse states are signaled by 'flag' files from distributed executions of the scripts pickedup periodically (20 seconds). The completed status is written directly to the associative table by the parser when it is done. With short scripts the complete status is written before the ready to parse flag file is picked up. Because the row from the table is cached, the complete status is not seen by the observer for the flag files and gets overwritten by the ready to parse status. This is not good. I need the status to be updated in the database in the correct sequence so an Ajax periodic query can inform the user of the status of each script and when the run ( consisting of one to many scripts ) is completed.

Can I force the ScriptRun.find(:id) to always go to the database? If so how? If not, why not???

© Stack Overflow or respective owner

Related posts about activerecord

Related posts about cache