Skip to content

Commit 35227fa

Browse files
committed
Rework the connects_to configuration in the README
Prefer suggesting YAML configuration and show the how the `database` and `databases` shorthands map to `connects_to`.
1 parent f3d5aaa commit 35227fa

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,31 @@ config.cache_store = :solid_cache_store
8888

8989
You can set one of `database`, `databases` and `connects_to` in the config file. They will be used to configure the cache databases in `SolidCache::Record#connects_to`.
9090

91-
Setting `database` to `cache_db` will configure with:
91+
If `connects_to` is set, it will be passed directly.
9292

93-
```ruby
94-
SolidCache::Record.connects_to database: { writing: :cache_db }
93+
Setting `database` is shorthand for connecting to a single database:
94+
95+
```yaml
96+
database: :cache_db
97+
# equivalent to
98+
connects_to:
99+
database:
100+
writing: :cache_db
95101
```
96102

97-
Setting `databases` to `[cache_db, cache_db2]` is the equivalent of:
103+
And `databases` to `[cache_db, cache_db2]` is the equivalent of:
98104

99-
```ruby
100-
SolidCache::Record.connects_to shards: { cache_db1: { writing: :cache_db1 }, cache_db2: { writing: :cache_db2 } }
105+
```yaml
106+
databases: [cache_db, cache_db2]
107+
# equivalent to
108+
connects_to:
109+
shards:
110+
cache_db1:
111+
writing: :cache_db1
112+
cache_db2:
113+
writing: :cache_db2
101114
```
102115

103-
If `connects_to` is set, it will be passed directly.
104-
105116
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.
106117

107118
### Engine configuration

0 commit comments

Comments
 (0)