Skip to content

feat: Add first-class Valkey support with GLIDE-backed store#437

Open
janisto wants to merge 2 commits intofastify:mainfrom
janisto:valkey-support
Open

feat: Add first-class Valkey support with GLIDE-backed store#437
janisto wants to merge 2 commits intofastify:mainfrom
janisto:valkey-support

Conversation

@janisto
Copy link
Copy Markdown

@janisto janisto commented Mar 16, 2026

Adds first-class Valkey support to @fastify/rate-limit through a new valkey option backed by a dedicated ValkeyStore that uses @valkey/valkey-glide scripting APIs. It keeps the existing Redis path unchanged, adds runtime validation for mutually exclusive storage options, and updates the public type surface with a structural Valkey client interface.

It also adds documentation and examples for both direct GLIDE clients and @fastify/valkey-glide, plus expanded test coverage for Valkey behavior including ban, skipOnError, throw-on-error, continueExceeding, exponentialBackoff, route-scoped limits, and createRateLimit(). Verification now runs Redis and Valkey integration backends on separate ports so both suites can execute without cross-test interference.

Close #436

See fastify/fastify-valkey-glide#33

Checklist

Copilot AI review requested due to automatic review settings March 16, 2026 10:07
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

Adds first-class Valkey support to @fastify/rate-limit by introducing a new valkey configuration option backed by a GLIDE-scripted ValkeyStore, plus documentation/examples and new test coverage.

Changes:

  • Add ValkeyStore implementation using @valkey/valkey-glide scripting APIs and wire it into plugin initialization via settings.valkey.
  • Add runtime validation to enforce mutual exclusivity between store, redis, and valkey.
  • Extend TypeScript types, docs, examples, and add unit + integration tests for Valkey behavior.

Reviewed changes

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

Show a summary per file
File Description
index.js Adds valkey store selection and validates mutually exclusive store options.
store/ValkeyStore.js New GLIDE-backed store implementation using cached script invocation.
types/index.d.ts Adds FastifyRateLimitValkeyClient, adjusts option types (redis to unknown, valkey added).
types/index.test-d.ts Adds type-level coverage for valkey option and client interface.
test/valkey-store.test.js Unit tests for ValkeyStore key prefixing, child behavior, caching, and error forwarding.
test/valkey-rate-limit.test.js Plugin-level tests for valkey option and new mutual exclusivity validation.
test/valkey-real-rate-limit.test.js Real integration tests against a running Valkey backend (GLIDE client).
example/example-valkey-direct.mjs Example using a directly managed GLIDE client.
example/example-fastify-valkey-glide.mjs Example using @fastify/valkey-glide to supply the resolved client.
README.md Documents Valkey usage, installation guidance, and examples.
package.json Adds optional peer + dev dependency on @valkey/valkey-glide and a local valkey docker script.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread store/ValkeyStore.js
Comment on lines +45 to +46
err.message = 'Valkey support requires @valkey/valkey-glide to be installed'
throw err
Comment on lines +17 to +20
const VALKEY_ADDRESS = {
host: '127.0.0.1',
port: Number(process.env.VALKEY_PORT || 6380)
}
@janisto janisto changed the title Add first-class Valkey support with GLIDE-backed store feat: Add first-class Valkey support with GLIDE-backed store Mar 16, 2026
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.

Valkey support

2 participants