redis-semaphore icon indicating copy to clipboard operation
redis-semaphore copied to clipboard

Allow non-ioredis client

Open jokester opened this issue 1 year ago • 2 comments

This PR removes all ioredis imports from non-test code, and instanceof ioredis.Redis checks of redis clients.

Users can now use non-ioredis clients with this library, but are expected to provide ioredis-compatible API, marked by RedisClient type.

ioredis should work as before.

Fixes https://github.com/swarthy/redis-semaphore/issues/201 .

jokester avatar May 24 '24 16:05 jokester

It is now possible to make ioredis an optional peer dep, with peerDependenciesMeta:

  "peerDependenciesMeta": {
    "ioredis": {
      "optional": true
    }
  }

But it could be a breaking change so I'm not sure if we should. If user didn't have ioredis as explicit dependency this could break something in rare case.

jokester avatar May 24 '24 16:05 jokester

@jokester Hi! Thanks for PR! Please, check review comments.

If user didn't have ioredis as explicit dependency this could break something in rare case.

I guest we can mark it optional and release minor version, because command in README.md already contains ioredis. So it was a conscious decision by the user not to install ioredis explicitly for that rare case.

swarthy avatar May 24 '24 16:05 swarthy