use more optimal algorithm

This commit is contained in:
Lewis Crichton
2023-08-04 15:47:04 +01:00
parent a7aa654547
commit d422a3573f
+12 -2
View File
@@ -54,8 +54,18 @@ var (
Name: "vencord_accounts_registered",
Help: "The total number of accounts registered",
}, func() float64 {
// TODO: this is very unoptimized and may cripple the database if there are many keys in future
return float64(len(rdb.Keys(context.Background(), "secrets:").Val()))
iter := rdb.Scan(context.Background(), 0, "secrets:*", 0).Iterator()
var count int64
for iter.Next(context.Background()) {
count++
}
if err := iter.Err(); err != nil {
panic(err)
}
return float64(count)
})
)