Add Valkey (GLIDE) connection configuration#1
Conversation
Introduce a "valkey" connection block in config/database.php backed by the valkey-glide client. Every option falls back to its matching REDIS_* value, so existing Redis apps can adopt Valkey with zero new config — either by switching CACHE_STORE=valkey or setting VALKEY_FROM_REDIS=true to route existing "redis" bindings through Valkey transparently. Expose Valkey-native GLIDE capabilities (AZ affinity, IAM auth, reconnect strategy, client-side caching, compression, OpenTelemetry) as optional, default-off keys, plus cluster and TLS support. Add a valkey service to docker-compose.yml, with commented-out cluster nodes for local multi-node testing. Signed-off-by: Roberto Luna-Rojas <roberto.luna.rojas@gmail.com>
Enable the postgres service on postgres:18-alpine and comment out the mysql and redis services, making Postgres the default local database for docker-compose development. Signed-off-by: Roberto Luna-Rojas <roberto.luna.rojas@gmail.com>
The valkey connection fell back to bare env('REDIS_*') calls with no final
default, so an app with no REDIS_* or VALKEY_* variables set resolved host,
port, database, cluster, and retry options to null instead of the Redis
driver's sensible defaults. Add the hardcoded defaults as the final fallback
(127.0.0.1, 6379, db 0/1, cluster "redis", max_retries 3, etc.).
Promote az_affinity from a commented example to a live option key so the
availability-zone read affinity documented for read_from='az_affinity' is
actually configurable, and add inline documentation comments for every
option.
Signed-off-by: Roberto Luna-Rojas <roberto.luna.rojas@gmail.com>
The valkey block had grown far more verbose than the neighboring redis block, with per-key inline comments, a large commented native-options block, cluster examples, otel, and other keys beyond the driver's needs. Trim it to mirror the redis section's concise style: a doc-block header plus plain keys. Fold the Valkey-native options (use_tls, read_from, az_affinity) into the options array, matching how redis groups its own options. All REDIS_* fallbacks and sensible defaults are preserved. Signed-off-by: Roberto Luna-Rojas <roberto.luna.rojas@gmail.com>
The earlier simplification dropped the optional GLIDE capabilities entirely. Restore them as commented, disabled-by-default reference (timeouts, client_name, lazy_connect, inflight limit, phpredis aliases, IAM auth, reconnect strategy, client-side cache, compression, clusters, and OpenTelemetry) so the active config stays as concise as the redis block while still documenting what is available. Expand the section doc-block to list the Valkey-native options and their supported values, notably VALKEY_READ_FROM (primary, prefer_replica, az_affinity, any). Signed-off-by: Roberto Luna-Rojas <roberto.luna.rojas@gmail.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
| Filename | Overview |
|---|---|
| config/database.php | Adds a new valkey connection block mirroring the existing redis block, with VALKEY_* env vars falling back to REDIS_* equivalents and GLIDE-specific options (use_tls, read_from, az_affinity). The from_redis key placement at the top level may not be read by the driver if it inspects the options sub-array. |
| docker-compose.yml | Adds an active Valkey service but maps it to host port 6380, which conflicts with the config default of 6379 and will break local connections without manual env var overrides. Also swaps MySQL for PostgreSQL as the active database service, which is out of scope for this PR. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Application] --> B{VALKEY_FROM_REDIS?}
B -- true --> C[Use REDIS_* env vars]
B -- false --> D[Use VALKEY_* env vars]
C --> E[Valkey GLIDE Client]
D --> E
E --> F{Connection Type}
F -- default --> G["default connection\n(db 0)"]
F -- cache --> H["cache connection\n(db 1)"]
G --> I{Cluster?}
H --> I
I -- standalone --> J["Single Node\nhost:port"]
I -- cluster --> K["Multi-Node\nclusters config"]
J --> L[Valkey Server :6379]
K --> L
subgraph docker["docker-compose (local dev)"]
M["valkey service\nhost:6380 → container:6379"]
end
L -.->|port mismatch 6379 vs 6380| M
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Application] --> B{VALKEY_FROM_REDIS?}
B -- true --> C[Use REDIS_* env vars]
B -- false --> D[Use VALKEY_* env vars]
C --> E[Valkey GLIDE Client]
D --> E
E --> F{Connection Type}
F -- default --> G["default connection\n(db 0)"]
F -- cache --> H["cache connection\n(db 1)"]
G --> I{Cluster?}
H --> I
I -- standalone --> J["Single Node\nhost:port"]
I -- cluster --> K["Multi-Node\nclusters config"]
J --> L[Valkey Server :6379]
K --> L
subgraph docker["docker-compose (local dev)"]
M["valkey service\nhost:6380 → container:6379"]
end
L -.->|port mismatch 6379 vs 6380| M
Reviews (1): Last reviewed commit: "docs(database): Restore optional Valkey ..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docker-compose.yml`:
- Around line 80-84: The Valkey service is exposing host port 6380 while the
default Redis/Valkey config still assumes 6379, so update the docker-compose
Valkey mapping to match the default port or make the port override explicit in
config/database.php. Use the valkey service definition and the database
configuration defaults together to keep host-side connections working without
requiring extra environment setup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f6236a5f-5ef3-4143-842f-b42cf8ef2b60
📒 Files selected for processing (2)
config/database.phpdocker-compose.yml
| valkey: | ||
| image: valkey/valkey:9-alpine | ||
| ports: | ||
| - "6380:6379" | ||
| restart: always |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== docker-compose.yml excerpt ==\n'
nl -ba docker-compose.yml | sed -n '70,95p'
printf '\n== config/database.php excerpt ==\n'
nl -ba config/database.php | sed -n '1,220p'
printf '\n== valkey/redis env references ==\n'
rg -n "VALKEY_PORT|REDIS_PORT|valkey|redis" .env* config docker-compose.yml README* -g '!vendor'Repository: opensource-for-valkey/php-laravel-framework
Length of output: 255
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== docker-compose.yml excerpt ==\n'
awk 'NR>=70 && NR<=95 { printf "%4d %s\n", NR, $0 }' docker-compose.yml
printf '\n== config/database.php excerpt ==\n'
awk 'NR>=1 && NR<=220 { printf "%4d %s\n", NR, $0 }' config/database.php
printf '\n== valkey/redis env references ==\n'
rg -n "VALKEY_PORT|REDIS_PORT|valkey|redis" .env* config docker-compose.yml README* -g '!vendor'Repository: opensource-for-valkey/php-laravel-framework
Length of output: 14969
Align the Valkey host port with the default config
The service publishes 6380:6379, but config/database.php still falls back to REDIS_PORT=6379 for Valkey. Host-side connections will miss unless VALKEY_PORT=6380 is set; either map 6379:6379 or document the override.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docker-compose.yml` around lines 80 - 84, The Valkey service is exposing host
port 6380 while the default Redis/Valkey config still assumes 6379, so update
the docker-compose Valkey mapping to match the default port or make the port
override explicit in config/database.php. Use the valkey service definition and
the database configuration defaults together to keep host-side connections
working without requiring extra environment setup.
| valkey: | ||
| image: valkey/valkey:9-alpine | ||
| ports: | ||
| - "6380:6379" | ||
| restart: always |
There was a problem hiding this comment.
Port mismatch between docker service and config defaults
The valkey service exposes host port 6380 ("6380:6379"), but config/database.php defaults VALKEY_PORT to 6379. A developer who runs docker-compose up and relies on the default env values will get a connection refused error — the framework tries :6379 while Valkey listens on host :6380. Either map the container to the same host port ("6379:6379") so the config defaults work without any extra env, or document that VALKEY_PORT=6380 must be set when using this compose file.
| postgres: | ||
| image: postgres:18-alpine | ||
| environment: | ||
| POSTGRES_PASSWORD: "secret" | ||
| POSTGRES_DB: "forge" | ||
| ports: | ||
| - "5432:5432" | ||
| restart: always |
There was a problem hiding this comment.
Unrelated service swap from MySQL to PostgreSQL
This PR's stated scope is adding Valkey support, but it also replaces the active MySQL service with PostgreSQL. Contributors relying on this docker-compose.yml for MySQL-based development workflows will find their database service no longer starts by default. The MySQL-to-PostgreSQL switch deserves its own PR or at minimum a note in the PR description explaining why it is bundled here.
There was a problem hiding this comment.
.ditto
Any reason why we are modifying the defaults? We should be making additive changes not forcing to use Postgres over Mysql, same for Valkey and Redis
|
|
||
| 'valkey' => [ | ||
|
|
||
| 'from_redis' => env('VALKEY_FROM_REDIS', false), |
There was a problem hiding this comment.
from_redis placement may be silently ignored by the driver
from_redis lives at the top level of the valkey config array, sibling to client, options, default, and cache. If the GLIDE driver reads driver-level flags from the options sub-array (as most Laravel connection drivers do), this key will never be seen and the fallback behaviour will silently not work. It may belong inside options alongside the other driver flags (use_tls, read_from, etc.), or the driver's config-reading path should be confirmed to look one level up.
| postgres: | ||
| image: postgres:18-alpine | ||
| environment: | ||
| POSTGRES_PASSWORD: "secret" | ||
| POSTGRES_DB: "forge" | ||
| ports: | ||
| - "5432:5432" | ||
| restart: always |
There was a problem hiding this comment.
.ditto
Any reason why we are modifying the defaults? We should be making additive changes not forcing to use Postgres over Mysql, same for Valkey and Redis
|
|
||
| 'valkey' => [ | ||
|
|
||
| 'from_redis' => env('VALKEY_FROM_REDIS', false), |
There was a problem hiding this comment.
I don't understand what this config does or what is it intended for?
Summary
Adds a
valkeyconnection block toconfig/database.php, backed by thevalkey-glideclient. This is the configuration groundwork for the Valkey driver (Phase 1).Every option falls back to its matching
REDIS_*value, so existing Redis apps can adopt Valkey with zero new configuration — either by switchingCACHE_STORE=valkeyor settingVALKEY_FROM_REDIS=trueto route existingredisbindings through Valkey.The section deliberately mirrors the neighboring
redisblock for consistency: a doc-block header plus plain keys, with the Valkey-native options (use_tls,read_from,az_affinity) folded into theoptionsarray. Advanced GLIDE capabilities (IAM auth, reconnect strategy, client-side caching, compression, clustering, OpenTelemetry) are included as commented, disabled-by-default reference.Changes
config/database.php— newvalkeyconnection block withREDIS_*fallbacks and Redis-parity defaults; doc-block documents supported values (e.g.VALKEY_READ_FROM:primary | prefer_replica | az_affinity | any).docker-compose.yml— add avalkeyservice (plus commented cluster nodes) for local testing.Testing
php -l config/database.php— no syntax errors.127.0.0.1, port6379, db0/1,max_retries3, etc.).PASS.Notes
13.x(unrelated upstream PRs, no overlap with these files, so conflict-free).Closes laravel#7
Summary by CodeRabbit
New Features
Bug Fixes