You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using solid_cache with a different database for caching (e.g., PostgreSQL for main app, SQLite3 for cache), the SolidCache::Entry model doesn't automatically use the cache: configuration from database.yml. Instead, it inherits the default database connection (primary database).
Currently requires an explicit initializer to force the correct database connection:
# config/initializers/solid_cache.rbRails.application.config.to_preparedoSolidCache::Entry.establish_connection(adapter: "sqlite3",database: Rails.root.join("storage/#{Rails.env}_cache.sqlite3").to_s# This needs to match database.yml config for cache db)end
Expected Behavior
SolidCache::Entry should automatically use the database configuration from the cache: section in database.yml when it exists, similar to how other Rails engines handle multiple databases.
Suggestions?
If this is expected behavior, it would be helpful to document it in the README or guides, specifically:
That solid_cache requires explicit connection setup when using a different database, if different from main setup
The recommended initializer pattern shown in the workaround above? Don't know if this is the best approach, but open to suggestions.
Documenting simple ways to inspect the current solid_cache connection and configuration for debugging (took me digging through the code to find this.
# Verify actual database connectionSolidCache::Entry.connection.instance_variable_get(:@config)# orSolidCache::Entry.connection
This would help users debug their setup and verify which database solid_cache is actually using.
Environment
Rails version: 7.2.2.1
solid_cache version: 1.0.6
Ruby version: 3.3.6
The text was updated successfully, but these errors were encountered:
Description
When using solid_cache with a different database for caching (e.g., PostgreSQL for main app, SQLite3 for cache), the
SolidCache::Entry
model doesn't automatically use thecache:
configuration fromdatabase.yml
. Instead, it inherits the default database connection (primary database).Current Behavior
With the following configuration:
And application config:
SolidCache::Entry
still connects to PostgreSQL instead of SQLite3:Workaround
Currently requires an explicit initializer to force the correct database connection:
Expected Behavior
SolidCache::Entry
should automatically use the database configuration from thecache:
section indatabase.yml
when it exists, similar to how other Rails engines handle multiple databases.Suggestions?
If this is expected behavior, it would be helpful to document it in the README or guides, specifically:
Documenting simple ways to inspect the current solid_cache connection and configuration for debugging (took me digging through the code to find this.
This would help users debug their setup and verify which database solid_cache is actually using.
Environment
The text was updated successfully, but these errors were encountered: