tsCreateRule method

Future tsCreateRule(
  1. String sourceKey,
  2. String destKey,
  3. String aggregator,
  4. int bucketDuration, {
  5. int? alignTimestamp,
  6. bool forceRun = false,
})

TS.CREATERULE sourceKey destKey AGGREGATION aggregator bucketDuration alignTimestamp

Create a compaction rule.

  • sourceKey: The source time series key.
  • destKey: The destination (compacted) time series key.
  • aggregator: The aggregation type (e.g., avg, sum, min, max).
  • bucketDuration: Duration of each bucket in milliseconds.
  • alignTimestamp: Optional alignment timestamp.
  • forceRun: Force execution on Valkey.

Implementation

Future<dynamic> tsCreateRule(
  String sourceKey,
  String destKey,
  String aggregator,
  int bucketDuration, {
  int? alignTimestamp,
  bool forceRun = false,
}) async {
  await checkValkeySupport('TS.CREATERULE', forceRun: forceRun);
  final cmd = <dynamic>[
    'TS.CREATERULE',
    sourceKey,
    destKey,
    'AGGREGATION',
    aggregator,
    bucketDuration
  ];
  if (alignTimestamp != null) {
    cmd.add(alignTimestamp);
  }
  return execute(cmd);
}