Skip to content

Add Valkey (GLIDE) connection configuration#1

Draft
rlunar wants to merge 5 commits into
13.xfrom
feat/valkey
Draft

Add Valkey (GLIDE) connection configuration#1
rlunar wants to merge 5 commits into
13.xfrom
feat/valkey

Conversation

@rlunar

@rlunar rlunar commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a valkey connection block to config/database.php, backed by the valkey-glide client. 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 switching CACHE_STORE=valkey or setting VALKEY_FROM_REDIS=true to route existing redis bindings through Valkey.

The section deliberately mirrors the neighboring redis block for consistency: a doc-block header plus plain keys, with the Valkey-native options (use_tls, read_from, az_affinity) folded into the options array. 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 — new valkey connection block with REDIS_* 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 a valkey service (plus commented cluster nodes) for local testing.

Testing

  • php -l config/database.php — no syntax errors.
  • Config parses with no env vars set and resolves to Redis-parity defaults (host 127.0.0.1, port 6379, db 0/1, max_retries 3, etc.).
  • Laravel Pint — PASS.

Notes

  • Draft: opening as draft while the rest of the Valkey driver work continues. Will move to "ready for review" once the driver is complete, ahead of proposing upstream.
  • The branch is currently 5 commits behind 13.x (unrelated upstream PRs, no overlap with these files, so conflict-free).

Closes laravel#7

Summary by CodeRabbit

  • New Features

    • Added support for Valkey as a cache/connection option, including configurable client, TLS, read routing, and cluster settings.
    • Updated the local service setup to use PostgreSQL and Valkey by default, with matching cluster configuration support.
  • Bug Fixes

    • Improved connection configuration fallbacks so Valkey settings can reuse Redis-style environment values when needed.

rlunar added 5 commits July 4, 2026 21:43
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>
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 079dc361-9879-42f4-b349-90a998ad9145

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/valkey

Comment @coderabbitai help to get the list of available commands.

@rlunar rlunar self-assigned this Jul 5, 2026
@rlunar
rlunar requested a review from adrianluna July 5, 2026 02:15
@rlunar rlunar added the enhancement New feature or request label Jul 5, 2026
@rlunar

rlunar commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator Author

@greptileai

@greptile-apps

greptile-apps Bot commented Jul 5, 2026

Copy link
Copy Markdown

Greptile Summary

This PR introduces a valkey connection block in config/database.php backed by the valkey-glide client, with every option falling back to its REDIS_* counterpart for zero-config adoption. It also updates docker-compose.yml to add a live Valkey service and swap MySQL for PostgreSQL.

  • The valkey config block is well-structured and closely mirrors the existing redis block, with GLIDE-native options (use_tls, read_from, az_affinity) and a rich set of commented advanced options (IAM auth, client-side caching, OpenTelemetry, etc.) as reference documentation.
  • The Valkey Docker service maps host port 6380 to container port 6379, which mismatches the config default of 6379 and will break local connections unless VALKEY_PORT=6380 is set manually.
  • The docker-compose change also bundles an unrelated swap of the active database service from MySQL to PostgreSQL, which affects contributors outside the scope of this PR.

Confidence Score: 3/5

The config change is additive and low-risk, but the docker-compose port mismatch will leave the Valkey service unreachable with default settings, and the unrelated MySQL→PostgreSQL swap affects contributors beyond the scope of this PR.

The valkey config block itself is well-formed and the REDIS_* fallback pattern is sound. The main concern is in docker-compose.yml: the Valkey service is exposed on host port 6380 while the framework config defaults to 6379, meaning a developer who runs docker-compose up and sets no env vars will get a failed connection. The MySQL-to-PostgreSQL swap is a secondary concern — it's out of scope and breaks the local database setup for contributors not expecting the change.

docker-compose.yml needs the most attention: the Valkey port mapping and the unrelated database service change both warrant a second look before merging.

Important Files Changed

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
Loading
%%{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
Loading

Reviews (1): Last reviewed commit: "docs(database): Restore optional Valkey ..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 27b2560 and c15392e.

📒 Files selected for processing (2)
  • config/database.php
  • docker-compose.yml

Comment thread docker-compose.yml
Comment on lines +80 to +84
valkey:
image: valkey/valkey:9-alpine
ports:
- "6380:6379"
restart: always

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ 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.

Comment thread docker-compose.yml
Comment on lines +80 to +84
valkey:
image: valkey/valkey:9-alpine
ports:
- "6380:6379"
restart: always

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 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.

Comment thread docker-compose.yml
Comment on lines +23 to +30
postgres:
image: postgres:18-alpine
environment:
POSTGRES_PASSWORD: "secret"
POSTGRES_DB: "forge"
ports:
- "5432:5432"
restart: always

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

.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

Comment thread config/database.php

'valkey' => [

'from_redis' => env('VALKEY_FROM_REDIS', false),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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.

Comment thread docker-compose.yml
Comment on lines +23 to +30
postgres:
image: postgres:18-alpine
environment:
POSTGRES_PASSWORD: "secret"
POSTGRES_DB: "forge"
ports:
- "5432:5432"
restart: always

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

.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

Comment thread config/database.php

'valkey' => [

'from_redis' => env('VALKEY_FROM_REDIS', false),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't understand what this config does or what is it intended for?

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants