Skip to content

Docs: Component connections#285

Merged
terabytesoftw merged 9 commits intoyiisoft:masterfrom
AugustMiller:docs/shared-component-config
Mar 3, 2026
Merged

Docs: Component connections#285
terabytesoftw merged 9 commits intoyiisoft:masterfrom
AugustMiller:docs/shared-component-config

Conversation

@AugustMiller
Copy link
Copy Markdown
Contributor

@AugustMiller AugustMiller commented Jan 21, 2026

Q A
Is bugfix?
New feature?
Breaks BC?
Fixed issues None

This is a documentation-only PR!

I am on the Craft CMS team, and we got a few reports of configuration issues after updating to version 2.1.0:

As best we could tell, this isn't the result of a bug per se, but rather a difference in how per-component connections need to be defined now that they are not initilized with a concrete class. This used to be an acceptable nested configuration array:

[
    'hostname' => 'localhost',
    'port' => 6379,
    'password' => 'pass',
    'database' => 0,
]

Now, a class key is required:

[
    'class' => yii\redis\Connection::class,
    'hostname' => 'localhost',
    'port' => 6379,
    'password' => 'pass',
    'database' => 0,
]

Anyone using the default connection (referred to by the component’s ID, 'redis') was not impacted. However, we have recommended using discrete connections for each component (cache, mutex, and sessions) due to the way flushing works when sharing a database.

This attempts to describe the tradeoffs involved with a centrally-defined connection (as its own redis component), versus discrete, nested connections for each component that uses it. It also modernizes some of the config syntax to use the ::class qualifier (rather than a string), adds a dedicated mutex page, and cleans up some grammar and cross-references, throughout.

Warning

I did not make corresponding changes to the adjacent Predis documentation, or to languages other than English.

Ultimately, it's a bit of an inversion in the recommendations—instead of saying "define your connection once; use it everywhere," the reality is that whether you use Redis in one component or many, you probably want to define the connection at the point of use.

@AugustMiller AugustMiller marked this pull request as ready for review March 2, 2026 23:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Documentation updates clarifying how Redis connections should be configured (especially per-component nested connections) and expanding the guide to cover mutex usage, in response to post-2.1.0 configuration confusion.

Changes:

  • Modernizes Redis component configuration examples (adds required class keys for nested connections; uses ::class syntax).
  • Adds a dedicated “Using the Mutex component” guide page and links it from the docs index.
  • Improves wording/grammar and adds operational guidance about isolating components via separate Redis databases (and Cache::$shareDatabase implications).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/guide/usage-commands.md Clarifies direct command usage and when executeCommand() is needed.
docs/guide/topics-session.md Updates session configuration examples and emphasizes per-component DB separation.
docs/guide/topics-predis-session.md Capitalization/wording cleanup for Predis session docs.
docs/guide/topics-predis-cache.md Updates Predis cache docs (but currently contains a broken class reference).
docs/guide/topics-mutex.md New mutex documentation page and configuration examples.
docs/guide/topics-cache.md Updates cache configuration guidance, adds DB separation + shareDatabase discussion.
docs/guide/installation.md Updates requirements/install/configuration prose and examples.
docs/guide/README.md Updates guide index (adds mutex page; capitalization).
README.md Updates top-level README wording and Redis requirement line.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This was copied from the cache page for consistency, but it was… too consistent. :)
Copy link
Copy Markdown
Contributor Author

@AugustMiller AugustMiller left a comment

Choose a reason for hiding this comment

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

One legitimate find, one red herring from the clanker.

@terabytesoftw terabytesoftw requested a review from a team March 3, 2026 00:33
@terabytesoftw terabytesoftw linked an issue Mar 3, 2026 that may be closed by this pull request
@terabytesoftw terabytesoftw merged commit f445ff6 into yiisoft:master Mar 3, 2026
@terabytesoftw
Copy link
Copy Markdown
Member

Thks 👍

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

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can not instantiate yii\redis\ConnectionInterface

4 participants