Skip to content

Commit

Permalink
chore: no unnecessary concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnagydavid committed Oct 2, 2024
1 parent 8adbce5 commit 56f5e11
Showing 1 changed file with 14 additions and 27 deletions.
41 changes: 14 additions & 27 deletions src/redisHashKeyValueDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,14 @@ export class RedisHashKeyValueDB implements CommonKeyValueDB, AsyncDisposable {
.hscanStream(this.keyOfHashField, {
match: `${table}:*`,
})
.flatMap(
keyValueList => {
const values: string[] = []
keyValueList.forEach((keyOrValue, index) => {
if (index % 2 !== 1) return
values.push(keyOrValue)
})
return values.map(v => Buffer.from(v))
},
{
concurrency: 16,
},
)
.flatMap(keyValueList => {
const values: string[] = []
keyValueList.forEach((keyOrValue, index) => {
if (index % 2 !== 1) return
values.push(keyOrValue)
})
return values.map(v => Buffer.from(v))
})
.take(limit || Infinity)
}

Expand All @@ -106,20 +101,12 @@ export class RedisHashKeyValueDB implements CommonKeyValueDB, AsyncDisposable {
.hscanStream(this.keyOfHashField, {
match: `${table}:*`,
})
.flatMap(
keyValueList => {
const entries = _chunk(keyValueList, 2)
return entries.map(([k, v]) => {
return [
this.keyToId(table, String(k)),
Buffer.from(String(v)),
] satisfies KeyValueDBTuple
})
},
{
concurrency: 16,
},
)
.flatMap(keyValueList => {
const entries = _chunk(keyValueList, 2)
return entries.map(([k, v]) => {
return [this.keyToId(table, String(k)), Buffer.from(String(v))] satisfies KeyValueDBTuple
})
})
.take(limit || Infinity)
}

Expand Down

0 comments on commit 56f5e11

Please sign in to comment.