Skip to content

Commit

Permalink
fix(redis): add Redis type
Browse files Browse the repository at this point in the history
closes #205
  • Loading branch information
Kikobeats committed Apr 25, 2024
1 parent e7c09b5 commit e819f7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/redis/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Store } from '@keyvhq/core'
import { Redis, RedisOptions } from 'ioredis'
import { Redis as IORedis, RedisOptions } from 'ioredis'

declare class KeyvRedis<TValue> implements Store<TValue> {
constructor (options?: KeyvRedis.Options)
constructor (redis: Redis)
constructor (redis: IORedis)
constructor (uri: string, options?: KeyvRedis.Options)

get (key: string): Promise<TValue>
Expand All @@ -19,6 +19,7 @@ declare namespace KeyvRedis {
uri?: string | undefined
emitErrors?: boolean | true
}
const Redis: typeof IORedis
}

export = KeyvRedis
6 changes: 6 additions & 0 deletions packages/redis/test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ new Keyv({
})

new KeyvRedis({ uri: 'redis://user:pass@localhost:6379' })

new KeyvRedis('redis://user:pass@localhost:6379', {
db: 1
})

new KeyvRedis('redis://user:pass@localhost:6379', {
uri: 'redis://user:pass@localhost:6379',
db: 1
})

const redis = new KeyvRedis('redis://user:pass@localhost:6379')

new Keyv({ store: redis })

new KeyvRedis.Redis('redis://user:pass@localhost:6379')

0 comments on commit e819f7a

Please sign in to comment.