Josh Sharpe wrote:
class PendingOrder < ActiveRecord::Base
Aug 10 19:43:38 prod-app1 foo: PendingOrder Load (0.6ms)
SELECT * FROM `pending_orders` LIMIT 1
Aug 10 19:43:39 prod-app1 foo: CACHE (0.0ms) SELECT * FROM
`pending_orders` WHERE (`pending_orders`.`id` = 221)
So the first query is legit -- but second query is cached, and so
forth. Every subsequent query ends up being a cached value, forever.
How can I make the above method *not* look at a cache?
Not forever! Subsequent queries are cached until an update changes the
underlying data. Isn't it good to read from the cache if the underlying
database hasn't changed?
I am assuming that "processed?" reads from a column in your
pending_orders table. If something in your application changes that
value then the query cache should be cleared automatically. However, if
that database change were to happen outside of your Rails application I
could see that your code could end up blocking forever.
In any case I would recommend adding some "circuit breaker" code to your
method to prevent blocking forever. Maybe some sort of timeout/watchdog
to limit the amount of time this method could block.