Skip to content

[12.x] Add configurable key prefix to ThrottleRequestsWithRedis#12

Open
JoshSalway wants to merge 2 commits into12.xfrom
fix/redis-throttle-key-prefix
Open

[12.x] Add configurable key prefix to ThrottleRequestsWithRedis#12
JoshSalway wants to merge 2 commits into12.xfrom
fix/redis-throttle-key-prefix

Conversation

@JoshSalway
Copy link
Owner

Summary

  • Adds a configurable key prefix to ThrottleRequestsWithRedis for Redis ACL compatibility
  • Redis-native rate limiting generates raw, non-namespaced keys (SHA-1 hashes) which break in Redis environments with ACL key pattern restrictions
  • The prefix can be set via setKeyPrefix() or by overriding getKeyPrefix() in a subclass
  • Defaults to empty string for full backward compatibility

Test plan

  • New test verifies key prefix is applied and rate limiting works with prefix
  • New test verifies setKeyPrefix() returns $this for fluent chaining

Fixes laravel#58279

🤖 Generated with Claude Code

JoshSalway and others added 2 commits March 19, 2026 05:20
Redis-native rate limiting via ThrottleRequestsWithRedis generates raw,
non-namespaced Redis keys (e.g., SHA-1 hashes). This breaks in Redis
environments where ACLs restrict access by key pattern (common in
managed Redis/Valkey services).

This adds a configurable key prefix that gets prepended to all Redis
keys used by the throttle middleware. The prefix defaults to empty
string for backward compatibility, but can be set via setKeyPrefix()
or by overriding getKeyPrefix() in a subclass.

Fixes laravel#58279

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that the key prefix is prepended to Redis keys and that
setKeyPrefix() returns the middleware instance for fluent chaining.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant