@@ -373,6 +373,18 @@ func (client *Client) IncrBy(key string, timestamp int64, value float64, options
373
373
return redis .Int64 (conn .Do (INCRBY_CMD , args ... ))
374
374
}
375
375
376
+ // Creates a new sample that increments the latest sample's value with an auto timestamp
377
+ func (client * Client ) IncrByAutoTs (key string , value float64 , options CreateOptions ) (int64 , error ) {
378
+ conn := client .Pool .Get ()
379
+ defer conn .Close ()
380
+
381
+ args , err := AddCounterArgs (key , - 1 , value , options )
382
+ if err != nil {
383
+ return - 1 , err
384
+ }
385
+ return redis .Int64 (conn .Do (INCRBY_CMD , args ... ))
386
+ }
387
+
376
388
// Creates a new sample that decrements the latest sample's value
377
389
func (client * Client ) DecrBy (key string , timestamp int64 , value float64 , options CreateOptions ) (int64 , error ) {
378
390
conn := client .Pool .Get ()
@@ -385,6 +397,18 @@ func (client *Client) DecrBy(key string, timestamp int64, value float64, options
385
397
return redis .Int64 (conn .Do (DECRBY_CMD , args ... ))
386
398
}
387
399
400
+ // Creates a new sample that decrements the latest sample's value with auto timestamp
401
+ func (client * Client ) DecrByAutoTs (key string , value float64 , options CreateOptions ) (int64 , error ) {
402
+ conn := client .Pool .Get ()
403
+ defer conn .Close ()
404
+
405
+ args , err := AddCounterArgs (key , - 1 , value , options )
406
+ if err != nil {
407
+ return - 1 , err
408
+ }
409
+ return redis .Int64 (conn .Do (DECRBY_CMD , args ... ))
410
+ }
411
+
388
412
// Add counter args for command TS.INCRBY/TS.DECRBY
389
413
func AddCounterArgs (key string , timestamp int64 , value float64 , options CreateOptions ) (redis.Args , error ) {
390
414
args := redis.Args {key , value }
0 commit comments