Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading