### Install Solid Cache Source: https://github.com/rails/solid_cache/blob/main/README.md Add Solid Cache to your project and install its database schema. This is the initial setup step for using Solid Cache. ```bash bundle add solid_cache bin/rails solid_cache:install ``` -------------------------------- ### Database Shard Configuration Example Source: https://github.com/rails/solid_cache/blob/main/README.md Example of how to configure database shards in database.yml for Solid Cache. ```yaml production: cache_shard1: database: cache1_production host: cache1-db cache_shard2: database: cache2_production host: cache2-db cache_shard3: database: cache3_production host: cache3-db ``` -------------------------------- ### Start Docker Compose for Databases Source: https://github.com/rails/solid_cache/blob/main/README.md Use this command to start the necessary database services for testing. ```shell $ docker compose up -d ``` -------------------------------- ### Configure Solid Cache YAML Source: https://github.com/rails/solid_cache/blob/main/README.md Example configuration for `config/cache.yml` or `config/solid_cache.yml` showing default, development, and production settings. ```yaml default: store_options: &default_store_options max_age: <%= 60.days.to_i %> namespace: <%= Rails.env %> size_estimate_samples: 1000 development: &development database: cache store_options: <<: *default_store_options max_size: <%= 256.gigabytes %> production: &production databases: [production_cache1, production_cache2] store_options: <<: *default_store_options max_size: <%= 256.gigabytes %> ``` -------------------------------- ### Cache Shard Configuration Example Source: https://github.com/rails/solid_cache/blob/main/README.md Example of how to configure cache shards in cache.yml for Solid Cache. ```yaml production: databases: [cache_shard1, cache_shard2, cache_shard3] ``` -------------------------------- ### Setup Database Schema for Target DB Source: https://github.com/rails/solid_cache/blob/main/README.md Set the TARGET_DB environment variable to 'mysql' or 'postgres' before running the database setup command. ```shell $ TARGET_DB=mysql bin/rails db:setup $ TARGET_DB=postgres bin/rails db:setup ``` -------------------------------- ### Configure MySQL/PostgreSQL/Trilogy Database for Solid Cache Source: https://github.com/rails/solid_cache/blob/main/README.md Example configuration for `config/database.yml` when using MySQL, PostgreSQL, or Trilogy for both the primary application database and the Solid Cache database. ```yaml production: primary: &primary_production <<: *default database: app_production username: app password: <%= ENV["APP_DATABASE_PASSWORD"] %> cache: <<: *primary_production database: app_production_cache migrations_paths: db/cache_migrate ``` -------------------------------- ### Configure SQLite Database for Solid Cache Source: https://github.com/rails/solid_cache/blob/main/README.md Example configuration for `config/database.yml` when using SQLite for both the primary application database and the Solid Cache database. ```yaml production: primary: <<: *default database: storage/production.sqlite3 cache: <<: *default database: storage/production_cache.sqlite3 migrations_paths: db/cache_migrate ``` -------------------------------- ### Custom Encryption Context Properties Source: https://github.com/rails/solid_cache/blob/main/README.md Example of setting custom encryptor and message serializer for Solid Cache encryption. ```ruby config.solid_cache.encryption_context_properties = { encryptor: ActiveRecord::Encryption::Encryptor.new, message_serializer: ActiveRecord::Encryption::MessageSerializer.new } ``` -------------------------------- ### Configure Multiple Cache Database Shards Source: https://github.com/rails/solid_cache/blob/main/README.md Configuration in `config/solid_cache.yml` to set up multiple database shards for Solid Cache. ```yaml databases: [cache_db, cache_db2] # equivalent to connects_to: shards: cache_db1: writing: :cache_db1 cache_db2: writing: :cache_db2 ``` -------------------------------- ### Configure Single Cache Database Connection Source: https://github.com/rails/solid_cache/blob/main/README.md Shorthand configuration in `config/solid_cache.yml` to connect to a single cache database. ```yaml database: :cache_db # equivalent to connects_to: database: writing: :cache_db ``` -------------------------------- ### Set Solid Cache Store Manually Source: https://github.com/rails/solid_cache/blob/main/README.md Manually configure the cache store to use Solid Cache in `config/environments/production.rb`. ```ruby # config/environments/production.rb config.cache_store = :solid_cache_store ``` -------------------------------- ### Run Tests for Target Database Source: https://github.com/rails/solid_cache/blob/main/README.md Specify the target database using TARGET_DB environment variable when running tests. ```shell $ TARGET_DB=mysql bin/rake test $ TARGET_DB=postgres bin/rake test ``` -------------------------------- ### Configure Solid Cache Engine Options Source: https://github.com/rails/solid_cache/blob/main/README.md Set engine-specific configuration options for Solid Cache within Rails application configuration. ```ruby Rails.application.configure do config.solid_cache.size_estimate_samples = 1000 end ``` -------------------------------- ### Enable Cache Encryption in application.rb Source: https://github.com/rails/solid_cache/blob/main/README.md Configuration to enable encryption for Solid Cache values in the application.rb file. ```ruby config.solid_cache.encrypt = true ``` -------------------------------- ### Run Tests for Specific Rails Version Source: https://github.com/rails/solid_cache/blob/main/README.md Use this command to execute tests for a particular Rails version managed by appraisal. ```shell bundle exec appraisal rails-7-1 bin/rake test ``` -------------------------------- ### Enable Cache Encryption in cache.yml Source: https://github.com/rails/solid_cache/blob/main/README.md Configuration to enable encryption for Solid Cache values directly in cache.yml. ```yaml production: encrypt: true ``` -------------------------------- ### Update Dependencies After Gemfile Changes Source: https://github.com/rails/solid_cache/blob/main/README.md Run these commands after modifying the Gemfile to ensure all Rails version dependencies are updated. ```shell $ bundle $ appraisal update ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.