database: cast float and time types in incrementalCounter.
Newer Redis version requires arguments types to be string or integer.
Change-Id: I5f3fba9affda3b0747372da824ca0662cc95a495
Reviewed-on: https://go-review.googlesource.com/78535
Reviewed-by: Ross Light <light@google.com>
diff --git a/database/database.go b/database/database.go
index 6a7dadd..c25dd5d 100644
--- a/database/database.go
+++ b/database/database.go
@@ -1199,9 +1199,10 @@
// lambda = math.Ln2 / thalf
c := db.Pool.Get()
defer c.Close()
+ d := strconv.FormatFloat(delta, 'f', -1, 64)
const lambda = math.Ln2 / float64(counterHalflife)
- scaledTime := lambda * float64(t.Sub(time.Unix(1257894000, 0)))
- return redis.Float64(incrementCounterScript.Do(c, key, delta, scaledTime, (4*counterHalflife)/time.Second))
+ scaledTime := strconv.FormatFloat(lambda*float64(t.Sub(time.Unix(1257894000, 0))), 'f', -1, 64)
+ return redis.Float64(incrementCounterScript.Do(c, key, d, scaledTime, int((4*counterHalflife)/time.Second)))
}
func (db *Database) IncrementCounter(key string, delta float64) (float64, error) {