fastify / fastify-rate-limit

A low overhead rate limiter for your routes
MIT License
488 stars 68 forks source link

Support node-redis, possibly along with ioredis? #368

Open yshrsmz opened 4 months ago

yshrsmz commented 4 months ago

Prerequisites

🚀 Feature Proposal

Add support for redis package.

Motivation

According to the issue in ioredis(https://github.com/redis/ioredis/issues/1870#issuecomment-2029351413), the future mainstream package is going to be redis, not ioredis.

So I think it's a good idea to support redis package.

Example

No response

mcollina commented 4 months ago

Indeed. However Redis is not OSS anymore :'(. I'm generically planning to migrate everything to iovalkey that I plan to maintain.

yshrsmz commented 4 months ago

That sounds good!

I'd like to propose another idea. Is it possible to make it more pluggable? I mean, it would be great if we could use any caching mechanism with this plugin.

For example, split the lib into 2(or more) packages. One is @fastify/rate-limit-core, and another is @fastify/rate-limit-ioredis.

@fastify/rate-limit-core provides core fastify plugin implementation and an interface for the caching mechanism, along with its local in-memory implementation. And @fastify/rate-limit-ioredis provides ioredis implementation for the interface.

This way, if we want to use node-redis or any other caching solution, we can develop a custom implementation while using this plugin.