Problem
The current router DB backend simply iterates over all keys in each backend, same with count. This isn't necessarily correct, because it doesn't take into account which keys would actually be used, based on the prefix configured.
async * iterKeys () {
for (const backend of new Set(Object.values(this.backends))) {
yield * backend.iterKeys()
}
}
async keyCount () {
let count = 0
for (const backend of new Set(Object.values(this.backends))) {
count += await backend.keyCount()
}
return count
}
Example:
Configuration is:
[database.backendOptions.router]
"*" = { name = "fs", options = { } }
z = { name = "redis", options = { } }
Say that redis has a key called foo. This would be reported both in iterKeys and keyCount, even though the redis backend will never be used for this key.
Solution
Improve the logic to report only relevant keys.
Problem
The current
routerDB backend simply iterates over all keys in each backend, same with count. This isn't necessarily correct, because it doesn't take into account which keys would actually be used, based on the prefix configured.Example:
Configuration is:
Say that
redishas a key calledfoo. This would be reported both initerKeysandkeyCount, even though theredisbackend will never be used for this key.Solution
Improve the logic to report only relevant keys.