diff options
author | Tsukasa OISHI <oishi_t@kakaku.com> | 2017-06-28 14:12:12 +0900 |
---|---|---|
committer | Tsukasa OISHI <tsukasa.oishi@gmail.com> | 2017-06-29 01:34:48 +0900 |
commit | 1b4360dea81b0c04589a62b8af7c555cfc0509ca (patch) | |
tree | adf870f1e61802d958e42dd18f093f891d517fde /activejob/lib/active_job/enqueuing.rb | |
parent | 5241b265126ac9ecadf1414feaf4c42ceb056432 (diff) | |
download | rails-1b4360dea81b0c04589a62b8af7c555cfc0509ca.tar.gz rails-1b4360dea81b0c04589a62b8af7c555cfc0509ca.tar.bz2 rails-1b4360dea81b0c04589a62b8af7c555cfc0509ca.zip |
Enable query cache if set a configurations
ActiveRecord query cache is available when a connection is connected.
Therefore, query cache is unavailable when entering the ActiveRecord::Base.cache block without being connected.
```ruby
ActiveRecord::Base.cache do
Task.find(1) # access to database.
Task.find(1) # access to database. unavailable query cache
end
```
If we use query cache with batch script etc, we need to connect before that.
```ruby
Task.connection
ActiveRecord::Base.cache do
Task.find(1) # access to database.
Task.find(1) # available query cache
end
```
Before version 3.1, query cache had been enabled if a configuration was set up.
In order to solve the `DATABASE_URL` issue(#8074), ActiveRecord has checked whether a connection is connected or not.
Today, ActiveRecord.configurations respect `DATABASE_URL`.
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/core.rb#L46
Diffstat (limited to 'activejob/lib/active_job/enqueuing.rb')
0 files changed, 0 insertions, 0 deletions