topkAdd method

Future<List<String?>> topkAdd(
  1. String key,
  2. List<String> items, {
  3. bool forceRun = false,
})

TOPK.ADD key item item ... Adds one or more items to the TopK data structure. Returns a list of elements dropped from the TopK list. Null indicates no drop.

Implementation

Future<List<String?>> topkAdd(
  String key,
  List<String> items, {
  bool forceRun = false,
}) async {
  await checkValkeySupport('TOPK.ADD', forceRun: forceRun);

  final result = await execute(['TOPK.ADD', key, ...items]);
  if (result is List) {
    return result.map((e) => e?.toString()).toList();
  }
  return [];
}