swarthy / redis-semaphore

Distributed mutex and semaphore based on Redis
MIT License
148 stars 28 forks source link

Support for ioredis-mock #201

Closed germanescobar closed 3 months ago

germanescobar commented 8 months ago

Hi,

I have a case in which I need to pass an ioredis-mock instance for testing but I get the following error:

"client" must be instance of ioredis client or cluster

Is there a solution or workaround for this case?

Thanks!

jokester commented 5 months ago

I had similar questions too. Is it really necessary to require a strict ioredis instance?

In my case I wanted to pass a duck-type compatible client, backed by redis-over-http client

jokester commented 3 months ago

If maintainers thinks it's fine I'm happy to do something. I personally wanted a mutex that work with Upstash serverless redis.

The idea on my head is, to extract a ioredis-like interface and rely on the interface instead of instanceof check. Since only a few Redis APIs are required, I imagine the interface to be small. Other redis clients, even if they happen to name APIs differently, can be used with an adapter.

swarthy commented 3 months ago

@jokester Hi! PR is welcome

swarthy commented 3 months ago

Support for ioredis-mock added in v5.6.0