-
Notifications
You must be signed in to change notification settings - Fork 214
Improved redis kv stores #666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 09544f1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@tus/[email protected] |
* main: Format @tus/s3-store: fix expiration tags in readme (tus#665)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added changesets, docs, and ioredis
to optionalDependencies
otherwise the implementation can expect a different version than is used.
Code LGTM but we don't have automated tests for this. Can you confirm this works as expected locally?
Yes. I wasn't familiar with how your tests are set up, but I ran some local tests to make sure. Should be easy enough to adapt. import {createClient} from '@redis/client'
import {RedisKvStore} from './RedisKvStore'
import {IoRedisKvStore} from './IoRedisKvStore'
import {Redis} from 'ioredis'
import {randomUUID} from 'node:crypto'
const ioRedis = new Redis()
const redis = createClient()
const prefix = `kvstore-test:${Date.now()}:`
const store = new RedisKvStore(redis, prefix)
const ioStore = new IoRedisKvStore(ioRedis, prefix)
const run = async () => {
const values: string[] = []
for (let i = 0; i < 25; i++) {
const value = randomUUID()
values.push(value)
await redis.set(`${prefix}${value}`, value, {EX: 60})
}
const ioList = await ioStore.list()
const list = await store.list()
console.log(list.length === values.length)
console.log(ioList.length === values.length)
}
redis.connect().then(() => {
run().then(() => {
redis.disconnect().then(() => {
process.exit(0)
})
})
}) |
Use
SCAN
instead ofKEYS
when getting ids from Redis KV store.From redis docs:
Add support for ioredis
Added a new IoRedisKvStore.
SCAN
and raw command method signatures aren't compatible between node-redis and ioredis. Separate class is more maintainable and safer than making the redis client type an union and trying to figure out which client it's using at runtime.