diff --git a/README.md b/README.md index a6942ce..b0a187d 100644 --- a/README.md +++ b/README.md @@ -56,25 +56,25 @@ Configuration will be read from `config/cache.yml` or `config/solid_cache.yml`. The format of the file is: ```yml -default: - store_options: &default_store_options +shared: + store_options: max_age: <%= 60.days.to_i %> namespace: <%= Rails.env %> size_estimate_samples: 1000 -development: &development +development: database: cache store_options: - <<: *default_store_options max_size: <%= 256.gigabytes %> -production: &production +production: databases: [production_cache1, production_cache2] store_options: - <<: *default_store_options max_size: <%= 256.gigabytes %> ``` +The `shared` key is read by Rails' `config_for` and deep merged into the configuration of every environment, with the environment's own values taking precedence. + For the full list of keys for `store_options` see [Cache configuration](#cache-configuration). Any options passed to the cache lookup will overwrite those specified here. After running `solid_cache:install`, `environments/production.rb` will replace your cache store with Solid Cache, but you can also do this manually: diff --git a/lib/generators/solid_cache/install/templates/config/cache.yml.tt b/lib/generators/solid_cache/install/templates/config/cache.yml.tt index 70a2ac6..52b4a16 100644 --- a/lib/generators/solid_cache/install/templates/config/cache.yml.tt +++ b/lib/generators/solid_cache/install/templates/config/cache.yml.tt @@ -1,16 +1,9 @@ -default: &default +shared: store_options: # Cap age of oldest cache entry to fulfill retention policies # max_age: <%%= 60.days.to_i %> max_size: <%%= 256.megabytes %> namespace: <%%= Rails.env %> -development: - <<: *default - -test: - <<: *default - production: database: <%= ENV.fetch("DATABASE", "cache") %> - <<: *default diff --git a/test/lib/generators/solid_cache/solid_cache/install_generator_test.rb b/test/lib/generators/solid_cache/solid_cache/install_generator_test.rb index fd12cbc..83ce8f8 100644 --- a/test/lib/generators/solid_cache/solid_cache/install_generator_test.rb +++ b/test/lib/generators/solid_cache/solid_cache/install_generator_test.rb @@ -71,22 +71,15 @@ class SolidCache::InstallGeneratorTest < Rails::Generators::TestCase private def expected_cache_config <<~YAML - default: &default + shared: store_options: # Cap age of oldest cache entry to fulfill retention policies # max_age: <%= 60.days.to_i %> max_size: <%= 256.megabytes %> namespace: <%= Rails.env %> - development: - <<: *default - - test: - <<: *default - production: database: cache - <<: *default YAML end end