<commit_before>package com.github.j5ik2o.reactive.redis.feature

import java.util.UUID

import cats.data.NonEmptyList
import com.github.j5ik2o.reactive.redis._
import com.github.j5ik2o.reactive.redis.command.sets.{ SAddFailed, SAddRequest, SAddSucceeded, SAddSuspended }

trait SetsFeature { this: RedisClient =>

  def sAdd(key: String, member: String, members: String*): ReaderTTaskRedisConnection[Result[Long]] =
    sAdd(key, NonEmptyList.of(member, members: _*))

  def sAdd(key: String, members: NonEmptyList[String]): ReaderTTaskRedisConnection[Result[Long]] =
    send(SAddRequest(UUID.randomUUID(), key, members)).flatMap {
      case SAddSuspended(_, _)        => ReaderTTask.pure(Suspended)
      case SAddSucceeded(_, _, value) => ReaderTTask.pure(Provided(value))
      case SAddFailed(_, _, ex)       => ReaderTTask.raiseError(ex)
    }

  /*
 * SCARD
 * SDIFF
 * SDIFFSTORE
 * SINTER
 * SINTERSTORE
 * SISMEMBER
 * SMEMBERS
 * SMOVE
 * SPOP
 * SRANDMEMBER
 * SREM
 * SSCAN
 * SUNION
 * SUNIONSTORE
 */
}<commit_msg>add SetsAPI trait<commit_after>package com.github.j5ik2o.reactive.redis.feature

import java.util.UUID

import cats.data.NonEmptyList
import com.github.j5ik2o.reactive.redis._
import com.github.j5ik2o.reactive.redis.command.sets.{ SAddFailed, SAddRequest, SAddSucceeded, SAddSuspended }

trait SetsAPI[M[_]] {
  def sAdd(key: String, member: String, members: String*): M[Result[Long]]
  def sAdd(key: String, members: NonEmptyList[String]): M[Result[Long]]
}

trait SetsFeature extends SetsAPI[ReaderTTaskRedisConnection] { this: RedisClient =>

  override def sAdd(key: String, member: String, members: String*): ReaderTTaskRedisConnection[Result[Long]] =
    sAdd(key, NonEmptyList.of(member, members: _*))

  override def sAdd(key: String, members: NonEmptyList[String]): ReaderTTaskRedisConnection[Result[Long]] =
    send(SAddRequest(UUID.randomUUID(), key, members)).flatMap {
      case SAddSuspended(_, _)        => ReaderTTask.pure(Suspended)
      case SAddSucceeded(_, _, value) => ReaderTTask.pure(Provided(value))
      case SAddFailed(_, _, ex)       => ReaderTTask.raiseError(ex)
    }

  /*
 * SCARD
 * SDIFF
 * SDIFFSTORE
 * SINTER
 * SINTERSTORE
 * SISMEMBER
 * SMEMBERS
 * SMOVE
 * SPOP
 * SRANDMEMBER
 * SREM
 * SSCAN
 * SUNION
 * SUNIONSTORE
 */
}
{'fraction_non_alphanumeric': 0.1257615317667537, 'fraction_numerical': 0.005221932114882507, 'mean_word_length': 4.553140096618358, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4156889', 'n_tokens_mistral': 851, 'n_tokens_neox': 809, 'n_words': 148}