fix(zset): preserve double precision during migration (#940)

This commit resolves the ZSET score truncation issue caused by using `%f` format specifier, which led to loss of precision for double values.
This commit is contained in:
trynocoding 2025-03-21 15:24:41 +08:00 committed by GitHub
parent 4a24a47ff4
commit eb8703fb4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -48,7 +48,7 @@ func (o *ZsetObject) readZset() {
for i := 0; i < size; i++ {
member := structure.ReadString(rd)
score := structure.ReadFloat(rd)
o.cmdC <- RedisCmd{"zadd", o.key, fmt.Sprintf("%f", score), member}
o.cmdC <- RedisCmd{"zadd", o.key, fmt.Sprintf("%.17g", score), member}
}
}
@ -58,7 +58,7 @@ func (o *ZsetObject) readZset2() {
for i := 0; i < size; i++ {
member := structure.ReadString(rd)
score := structure.ReadDouble(rd)
o.cmdC <- RedisCmd{"zadd", o.key, fmt.Sprintf("%f", score), member}
o.cmdC <- RedisCmd{"zadd", o.key, fmt.Sprintf("%.17g", score), member}
}
}