Note that there are some explanatory texts on larger screens.

plurals
  1. POCache strategy for rails where new objects appearing invalidates the cache
    text
    copied!<p>I'm not seeing something obvious re:caching strategies in rails.</p> <p>I have a prices table that logs prices at particular times. So the current price would be the last row added to the prices table. Very frequently, the table is queried to display the entries, so caching that fetching would be great to stop (very) frequent queries hitting the database.</p> <p>So as far as I can see it would be fine for my entire app to cache that data completely <em>until a new row gets added</em>. </p> <p>Does rails caching handle that well? I see examples for on update of an active record object you expire the cache and force the updated object to be retrieved again - but I want the collection of objects (e.g. Price.find(:all) to be cached until Price.find(:all) contains a new object. So adding a new row to the db would have to expire the cache and force a new retrieval - the new price might be the latest for a few days, or it might only last a few minutes.)</p> <p>If not self-evident, this is the first time I've ever looked at caching. I'll be attempting to deploy memcache on heroku.</p> <p>Thanks a lot!</p> <p><strong>Edit</strong>: Just thought it might be useful to point out that the rails controllers only render JSON requests - rich single page app - so the main things to cache are the database query. This is why it is confusing me, I see partial caching, page caching, but I'm struggling to understand the type of caching I'm hopefully describing above.</p> <p>Dave</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload