Topic: How to pre-cache an array for an often called action ?

Hi, i have this tricky problem:

In my view i trigger an action very often before submit(cant change this).
The action reads  a file and creates an array. Then after some computing it sends some data back to the view. (view -> action -> reads_file -> creates some data aray -computes -> send data back)

The data in the file changes very rarely. Maybe once a month. Its obvious that its redundant to read the file and create the dataarray on every :action call.

How can I cache it?


Robert

Last edited by rambus (2007-07-26 16:31:11)

Re: How to pre-cache an array for an often called action ?

you could put the read code in environment.rb and save the array in a Constant.
The downside is that you would have to restart your mongrels when the file is  changed.

Re: How to pre-cache an array for an often called action ?

The data-file is updated once a month with new calculations