Sorted Sets API

Purely functional interface for the Sorted Sets API.

Sorted Set Commands usage

Once you have acquired a connection you can start using it:

import cats.effect.IO
import cats.syntax.all._
import dev.profunktor.redis4cats.effects.{Score, ScoreWithValue, ZRange}

val testKey = "zztop"

def putStrLn(str: String): IO[Unit] = IO(println(str))

commandsApi.use { cmd => // SortedSetCommands[IO, String, Long]
  for {
    _ <- cmd.zAdd(testKey, args = None, ScoreWithValue(Score(1), 1), ScoreWithValue(Score(3), 2))
    x <- cmd.zRevRangeByScore(testKey, ZRange(0, 2), limit = None)
    _ <- putStrLn(s"Score: $x")
    y <- cmd.zCard(testKey)
    _ <- putStrLn(s"Size: $y")
    z <- cmd.zCount(testKey, ZRange(0, 1))
    _ <- putStrLn(s"Count: $z")
  } yield ()
}