You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Thanks for sharing record-cache, it is pretty solid.
I am tinkering around with it and I notice that record cache seems to hit the cache even when I want to retrieve rows with a lock. Example:
transaction do
Item.lock("lock in share mode").where(:conditions).each do |i|
...
end
end
When I look at my SQL logs, I only see:
BEGIN
COMMIT
The actual select query is not there. When I disable record_cache and do the same thing again, the select query is there as expected. So it makes me believe that record cache is retrieving from cache even though I want to lock the rows in the db.
What would be the best way to get around this, so for any lock selects, record-cache is bypassed?
Thanks!
The text was updated successfully, but these errors were encountered:
To temporarily disable fetching records from the cache, you can use the following construct:
RecordCache::Base.without_record_cache do
transaction do
Item.lock("...").where...
end
end
And I just committed a more permanent fix that will automatically bypass any lock-select as suggested. This will be included in the next version.
PS. Instead of looking in the SQL logs, you can also switch on DEBUG logging (config.log_level = :debug in development.rb) to get more information on record-cache hits and misses.
Hi,
Thanks for sharing record-cache, it is pretty solid.
I am tinkering around with it and I notice that record cache seems to hit the cache even when I want to retrieve rows with a lock. Example:
transaction do
Item.lock("lock in share mode").where(:conditions).each do |i|
...
end
end
When I look at my SQL logs, I only see:
BEGIN
COMMIT
The actual select query is not there. When I disable record_cache and do the same thing again, the select query is there as expected. So it makes me believe that record cache is retrieving from cache even though I want to lock the rows in the db.
What would be the best way to get around this, so for any lock selects, record-cache is bypassed?
Thanks!
The text was updated successfully, but these errors were encountered: