Skip to content

Conversation

@trevorturk
Copy link
Contributor

Ref: rails/solid_queue#334

This adds a "Single database configuration" section to the README, similar to what exists in solid_queue. While running Solid Cache in a separate database is recommended for production use, this documentation helps users who want to use a single database for simplicity or in development environments.

FWIW I'd advocate for rails new to default to using a single database for the Solid stuff, but I think that ship has already sailed... ⛵ 👋 🤣

Similar to solid_queue, this documents how to configure Solid Cache
to use a single database instead of separate databases for the app
and cache.
@trevorturk trevorturk marked this pull request as ready for review August 12, 2025 19:00
@djmb
Copy link
Collaborator

djmb commented Nov 6, 2025

@trevorturk - if we use the same database for the cache, I think we'd still want to use a separate connection pool, otherwise cache writes get tied up in app transactions.

This could have unintended consequences like deadlocks or rollbacks undoing cache writes.

We could configure the app so that we have two connection pools that both point to the same database, something like:

production:
  primary: &primary_production
    <<: *default
    database: app_production
    username: app
    password: <%= ENV["APP_DATABASE_PASSWORD"] %>
  cache:
    <<: *primary_production
    database_tasks: false

However this is something we definitely wouldn't want to do with SQLite as only a single write transaction can be open at a time and separate connection pools to the same database could block each other. For SQLite I would always recommend a separate database.

@trevorturk
Copy link
Contributor Author

Ah interesting points, I hadn't considered. I'm mainly looking to have simple starter Rails apps up and running on Heroku, Render, etc with the Solid stack to keep the dependencies and services to a minimum.

I'm not sure if you want to consider writing more documentation considering the details and caveats you mention here, and just close this? I could also take a shot at updating this PR if you'd like. No worries here, really, thanks for the review!

@djmb
Copy link
Collaborator

djmb commented Nov 7, 2025

@trevorturk - yes I can do that. I'll keep this PR open as a reminder though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants