diff --git a/README.md b/README.md index 3a8174c..6c06a9d 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,30 @@ If `connects_to` is set, it will be passed directly. If none of these are set, Solid Cache will use the `ActiveRecord::Base` connection pool. This means that cache reads and writes will be part of any wrapping database transaction. +### Single database configuration + +Running Solid Cache in a separate database is recommended, but for PostgreSQL/MySQL/Trilogy you can use a single physical database and still keep separate connection pools for app and cache traffic. + +1. Move the schema from `db/cache_schema.rb` (or `db/cache_structure.sql`) into a normal app migration, then delete the cache schema file +2. Keep `database: cache` in `config/cache.yml` +3. Point `primary` and `cache` at the same database in `config/database.yml`, and disable database tasks for `cache`: + +```yaml +production: + primary: &primary_production + <<: *default + database: app_production + username: app + password: <%= ENV["APP_DATABASE_PASSWORD"] %> + cache: + <<: *primary_production + database_tasks: false +``` + +4. Run `bin/rails db:migrate` + +Do not use this setup with SQLite. SQLite allows only one write transaction at a time, so separate pools to the same database can block each other. For SQLite, use a separate cache database. + ### Engine configuration There are five options that can be set on the engine: