Skip to content

Use Solid Cache for the production Rails cache - #345

Open
thomasklemm wants to merge 1 commit into
basecamp:mainfrom
thomasklemm:deps/solid-cache
Open

thomasklemm wants to merge 1 commit into
basecamp:mainfrom
thomasklemm:deps/solid-cache

Conversation

@thomasklemm

@thomasklemm thomasklemm commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Moves the production Rails.cache from Redis to Solid Cache, in its own SQLite database that db:prepare creates. It's the first of three steps toward running Campfire without Redis: #346 moves the jobs and #347 Action Cable.

Entries aren't copied, so the cache starts cold after the upgrade. The cache database keeps SQLite's own WAL checkpoints, since the checkpoint contender only checkpoints the primary database. The restore hook deletes it rather than keep a copy taken from a running volume; it refills on demand. The HTTP benchmark now prepares the databases before starting Puma, so seeds made before a new database still boot.

@thomasklemm thomasklemm changed the title Use Solid Cache for the production Rails cache Use a dedicated SQLite database for Solid Cache Oct 8, 2026
@thomasklemm thomasklemm changed the title Use a dedicated SQLite database for Solid Cache Migrate caching from Redis to Solid Cache Oct 8, 2026
@dhh

dhh commented Oct 8, 2026

Copy link
Copy Markdown
Member

Reviewed the updated 47682c227697: the explicit cache wal_autocheckpoint: 1000 resolves the prior current-main integration issue, and the branch includes the latest Ruby4/Puma8 changes. The dedicated disposable cache database and restore cleanup look coherent by source review; I have not independently run the new branch's production tests. This leaves the hot whole-response/fragment MemoryStores unchanged and still requires Redis for Cable, so it is an operational cache-store choice rather than a demonstrated HTTP speedup. Please describe the new 256 MiB setting as Solid Cache's estimated eviction target, rather than a hard database/WAL-size bound. Before adopting the migration, the useful additional evidence is production first-boot/upgrade/restore, concurrent shared rate-limit increments/expiry, and eviction/WAL behavior with the current four-worker/one-thread layout. Holding the draft for those operational checks avoids attaching an unverified performance gain to the change.

GPT on behalf of DHH

@thomasklemm
thomasklemm marked this pull request as ready for review October 8, 2026 14:09
Copilot AI balanced review requested due to automatic review settings October 8, 2026 14:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@thomasklemm

Copy link
Copy Markdown
Contributor Author

Small fix in 3a59b4e, ready for another review: config/cache.yml carried database: <%= ENV.fetch("DATABASE", "cache") %> from the Solid Cache generator template, where it is evaluated once at generation time. Copied verbatim it ran on every boot, so an unrelated DATABASE variable in the host environment would have redirected the production cache. It now reads database: cache.

Production db:prepare creates production_cache.sqlite3 and Rails.cache round-trips through Solid Cache locally; unit suite and RuboCop pass, hosted CI is green.


Generated by Claude Code

@thomasklemm
thomasklemm force-pushed the deps/solid-cache branch 3 times, most recently from 9bea7be to 8c8551b Compare October 27, 2026 13:05
Rails.cache moves from Redis to Solid Cache, in its own SQLite database
that db:prepare creates from db/cache_schema.rb. Entries aren't copied, so
the cache starts cold after the upgrade.

The cache database keeps SQLite's own WAL checkpoints, since the
checkpoint contender only checkpoints the primary database. The restore
hook deletes it: a copy taken from a running volume can be torn, and the
cache refills on demand.

The HTTP benchmark prepares the databases before starting Puma, so a seed
made before a new database or migration still boots.
@thomasklemm thomasklemm changed the title Migrate caching from Redis to Solid Cache Use Solid Cache for the production Rails cache Nov 18, 2026
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.

3 participants