I put many question about caching in here but no one answer. So mayby i will have answer on this.
I have in my search model code like this:
users = users.where('id >?', my_value)
Rails.cache.fetch('my_cached',expires_in: 3.minutes) do
users = users.order('current_sign_in_at DESC')
end
Can somebody explain me what this do. I thought that this will return sorted users table and put it in cache for 3 minutes so when i require next search it will return me my_cached result if it doesnt expired.
But it does not work like that. When some user login and current_sign_in_at is changed - cache is override and new query is returned.