// ============ 集合命令 ============

///|
pub async fn Client::sadd(
  self : Client,
  key : String,
  members : Array[String],
) -> RedisInt {
  let args = ["SADD", key, ..members]
  self.send(args).to_int()
}

///|
pub async fn Client::srem(
  self : Client,
  key : String,
  members : Array[String],
) -> RedisInt {
  let args = ["SREM", key, ..members]
  self.send(args).to_int()
}

///|
pub async fn Client::smembers(self : Client, key : String) -> RedisArray {
  self.send(["SMEMBERS", key]).to_array()
}

///|
pub async fn Client::scard(self : Client, key : String) -> RedisInt {
  self.send(["SCARD", key]).to_int()
}

///|
pub async fn Client::sismember(
  self : Client,
  key : String,
  value : String,
) -> RedisInt {
  self.send(["SISMEMBER", key, value]).to_int()
}

///|
pub async fn Client::smismember(
  self : Client,
  key : String,
  members : Array[String],
) -> RedisArray {
  let args = ["SMISMEMBER", key, ..members]
  self.send(args).to_array()
}

///|
pub async fn Client::spop(self : Client, key : String) -> RedisString {
  self.send(["SPOP", key]).to_string()
}

///|
pub async fn Client::srandmember(self : Client, key : String) -> RedisString {
  self.send(["SRANDMEMBER", key]).to_string()
}

///|
pub async fn Client::smove(
  self : Client,
  source : String,
  destination : String,
  value : String,
) -> RedisInt {
  self.send(["SMOVE", source, destination, value]).to_int()
}

///|
pub async fn Client::sdiff(self : Client, keys : Array[String]) -> RedisArray {
  let args = ["SDIFF", ..keys]
  self.send(args).to_array()
}

///|
pub async fn Client::sdiffstore(
  self : Client,
  destination : String,
  keys : Array[String],
) -> RedisInt {
  let args = ["SDIFFSTORE", destination, ..keys]
  self.send(args).to_int()
}

///|
pub async fn Client::sinter(self : Client, keys : Array[String]) -> RedisInt {
  let args = ["SINTER", ..keys]
  self.send(args).to_int()
}

///|
pub async fn Client::sintercard(
  self : Client,
  numkeys : String,
  keys : Array[String],
) -> RedisInt {
  let args = ["SINTERCARD", numkeys, ..keys]
  self.send(args).to_int()
}

///|
pub async fn Client::sinterstore(
  self : Client,
  destination : String,
  keys : Array[String],
) -> RedisInt {
  let args = ["SINTERSTORE", destination, ..keys]
  self.send(args).to_int()
}

///|
pub async fn Client::sunion(self : Client, keys : Array[String]) -> RedisInt {
  let args = ["SUNION", ..keys]
  self.send(args).to_int()
}

///|
pub async fn Client::sunionstore(
  self : Client,
  destination : String,
  keys : Array[String],
) -> RedisInt {
  let args = ["SUNIONSTORE", destination, ..keys]
  self.send(args).to_int()
}

///|
pub async fn Client::sscan(
  self : Client,
  key : String,
  cursor : Int32,
  match_pattern? : String,
  count? : Int32,
) -> RedisArray {
  let args = ["SSCAN", key, cursor.to_string()]
  if match_pattern is Some(m) {
    args.push("MATCH \{m}")
  }
  if count is Some(c) {
    args.push("COUNT \{c}")
  }
  self.send(args).to_array()
}