3 ms·
This seems to be but a first step - it's currently limited only to calls of the form `Article.find(id)` and `Article.find_by_xxx(value)`. e.g. `Article.where(x
by ikawe 13y ago
This seems to be but a first step - it's currently limited only to calls of the form `Article.find(id)` and `Article.find_by_xxx(value)`.
e.g. `Article.where(xxx: value)` or `Article.where(xxx: value).last(3)` will not benefit from this improvement yet.
- tenderlove 13y agoIt's possible to do that in AdequateRecord, but I've purposely left the mechanism undocumented because the API is not stable. You can do something like this: statement = undocumented_method_call { |params| Article.where(xxx: params[:xxx]) } statement.execute xxx: "some value" https://github.com/rails/rails/blob/e5e440f477a0b5e06b008ee77e3c635049405957/activerecord/test/cases/statement_cache_test.rb#L18-L20 https://github.com/rails/rails/blob/e5e440f477a0b5e06b008ee7... The trick is that the cache only supports caching ActiveRecord::Relation objects, and not everyone knows which calls will return a Relation object. For now, I want to hide this API and make it as "automatic" as possible so that people don't have to change app code, but still get performance boosts.