Skip to content

Conversation

@xav-developer
Copy link
Contributor

@xav-developer xav-developer commented Oct 1, 2025

Description

When using prefix, the many method returns values with prefix

before

Array
(
    [:laravel:time] => 06:56:38
    [:laravel:date] => 2025-10-01
)

after

array (
  'time' => '06:55:17',
  'date' => '2025-10-01',
)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I wrote unit tests for my code (if tests is required for my changes)
  • I have made changes in CHANGELOG.md file

Summary by CodeRabbit

  • Bug Fixes

    • Fixed cache behavior when using key prefixes: the many() method now returns values mapped to the original (unprefixed) keys for consistent results with RoadRunner-backed caches.
  • Documentation

    • Added changelog entry under Unreleased → Fixed documenting the corrected many() behavior when a prefix is used.

@coderabbitai
Copy link

coderabbitai bot commented Oct 1, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Updated RoadRunnerStore::many to return an associative array keyed by the original (unprefixed) keys when a prefix is configured; added a CHANGELOG entry noting this fix.

Changes

Cohort / File(s) Summary of Changes
Cache store behavior
src/Cache/RoadRunnerStore.php
Modified many() to call backend getMultiple on prefixed keys then combine the returned values with the original unprefixed keys (using array_combine) so callers receive results keyed by original keys.
Changelog
CHANGELOG.md
Added an Unreleased -> Fixed entry describing that many() returns values with original keys when using a prefix.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Caller
  participant S as RoadRunnerStore
  participant B as Backend Storage

  Note over C,S: many(keys) -> ensure returned keys are original (unprefixed)

  C->>S: many([k1, k2, ...])
  alt prefix configured
    S->>B: getMultiple([prefix+k1, prefix+k2, ...])
    B-->>S: {prefix+k1: v1, prefix+k2: v2, ...}
    Note over S: Convert to array of values\nand array_combine([k1,k2,...], [v1,v2,...])
  else no prefix
    S->>B: getMultiple([k1, k2, ...])
    B-->>S: {k1: v1, k2: v2, ...}
  end
  S-->>C: {k1: v1, k2: v2, ...}
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Fix: many #163 — Also adjusts RoadRunnerStore::many to remap getMultiple results back to original unprefixed keys.

Poem

I hop through caches, nose to ground,
Unprefixing treasures that I found.
Keys reborn, all neat and true,
I bring them back — just for you. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title “Fix: many” references the method being changed but is too generic to convey what has actually been fixed; it does not indicate that the pull request updates the “many” cache method to strip prefixes from returned keys. Please update the title to clearly describe the core change, for example: “Fix cache RoadRunnerStore::many to return unprefixed keys” so that the intent is immediately clear to reviewers and future readers.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f83a31 and 513d5d3.

📒 Files selected for processing (1)
  • src/Cache/RoadRunnerStore.php (1 hunks)

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.1.28)

Path /fixes does not exist


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
CHANGELOG.md (1)

23-23: Clarify the changelog entry wording.

The current wording "returns values with prefix" is ambiguous—it could describe either the old buggy behavior or the new fixed behavior. Consider rephrasing to make it clear this describes the problem that was fixed.

Suggested rewording:

-- When using `prefix`, the `many` method returns values with `prefix`
+- When using `prefix`, the `many` method now returns values keyed by their original (unprefixed) keys

or:

-- When using `prefix`, the `many` method returns values with `prefix`
+- The `many` method incorrectly returned prefixed keys when a prefix was configured
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e57e856 and 6f83a31.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/Cache/RoadRunnerStore.php (1 hunks)
🔇 Additional comments (1)
src/Cache/RoadRunnerStore.php (1)

39-39: Verify getMultiple preserves order and returns entries for all requested keys
array_combine will throw if the returned values array length doesn’t match the input keys or if ordering differs. Manually confirm that Spiral\RoadRunner\KeyValue\StorageInterface::getMultiple always yields the same count and order (including nulls for missing keys), or else replace with a safe loop mapping each key to its value (defaulting to null).

@butschster butschster merged commit f7b7c23 into roadrunner-php:master Oct 1, 2025
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants