Skip to content

feat(redis): support ioredis v6 - #19

Open
mattstrayer wants to merge 1 commit into
Julien-R44:mainfrom
mattstrayer:feat/ioredis-v6
Open

feat(redis): support ioredis v6#19
mattstrayer wants to merge 1 commit into
Julien-R44:mainfrom
mattstrayer:feat/ioredis-v6

Conversation

@mattstrayer

Copy link
Copy Markdown

Closes #18

Problem

@verrou/core limits the ioredis peer range to ^5.3.2. ioredis 6.0.0 is now latest. When another dependency needs v6, pnpm installs a private second copy of v5 for verrou. The two copies have different type identities, so passing the app's v6 client to redisStore({ connection }) fails typecheck.

Changes

  1. Widen the peer range to ^5.3.2 || ^6.0.0.
  2. Type the connection option as a structural RedisConnection interface that lists the five commands the driver calls (set, setnx, eval, del, get). It replaces the import of the ioredis Redis class. A v5 client, a v6 client, a Redis<"resp3"> client and a Cluster instance all satisfy it, and the option no longer depends on the class shape.
  3. Add a type test that asserts Redis and Cluster match RedisConnection.
  4. Docs: note that v5 and v6 both work and that v6 needs Node.js 20 or newer.

The devDependency stays at ^5.8.2, so the lockfile is untouched.

Verification

With ioredis 5.8.2 installed:

  • tsc --noEmit: no errors
  • eslint .: no errors
  • pnpm build: passes
  • tests/drivers/redis.spec.ts against Redis 8: 27 tests pass

With ioredis 6.0.0 installed in place of 5.8.2:

  • tsc --noEmit: no errors
  • Same 27 tests pass
  • Redis<'resp3'> is assignable to RedisConnection

Widen the ioredis peer range to `^5.3.2 || ^6.0.0` so package managers
stop installing a private second copy when another dependency needs v6.

Type the `connection` option as a structural `RedisConnection` interface
that lists the five commands the driver calls, instead of the ioredis
`Redis` class. This accepts a v5 client, a v6 client, a `Redis<"resp3">`
client and a `Cluster` instance, and no longer depends on the class shape.

Closes Julien-R44#18
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.

Redis driver: support ioredis v6

1 participant