Closed adis-io closed 6 years ago
Why? What difference?
I use two rails apps in one machine. They have shared classes, models and etc through rails engine. So when I change values from one app changes not visible in other app.
It would be good if I can fetch values from DB something like that: Setting.mykey!
The exclamation mark variant is a good idea.
Another reason to bypass the cache is when you want to lock a setting when reading it (SELECT...FOR UPDATE
) to control exclusive access to a resource.
Same here. Value changes in the DB sometimes without the rails app noticing. So I need a way to invalidate the cache or reload directly.
Second that.
+1 for this.
+1. Is there any other way to reload setting?
Would love to load directly from DB as well
We can mark the settings (key/global) as stale and retrieve the new one for caching if we still want the performance gains. Much like a timestamp for last updated?
Same problem here, but on Elastic Beanstalk from Amazon. After update in form, rest of the app (like workers) doesn't know about change and still uses cached variable. How can I force to reload cached settings?
For object scoped settings, I found that this works:
@page = Page.find(params[:id])
@page.settings.unscoped.find_by(var: :setting_id, thing_id: @page.id, thing_type: 'Page')
I was wondering why was this closed? Was there a resolution/workaround to force reload?
@huacnlee Apologies for not getting what the line means. Could you elaborate a bit?
2.6.3 :002 > Setting.all
=> #<ActiveRecord::Relation [...]>
2.6.3 :002 > Setting.find_by(var: "setting_id")
For example, I want to read key from DB directly, not from cache. Is it possible?