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 dev.profunktor.redis4cats.effects.{Score, ScoreWithValue, ZRange}
val testKey = "zztop"
def putStrLn(str: String): IO[Unit] = IO(println(str))
commandsApi.use { redis => // SortedSetCommands[IO, String, Long]
for {
_ <- redis.zAdd(testKey, args = None, ScoreWithValue(Score(1), 1), ScoreWithValue(Score(3), 2))
x <- redis.zRevRangeByScore(testKey, ZRange(0, 2), limit = None)
_ <- putStrLn(s"Score: $x")
y <- redis.zCard(testKey)
_ <- putStrLn(s"Size: $y")
z <- redis.zCount(testKey, ZRange(0, 1))
_ <- putStrLn(s"Count: $z")
} yield ()
}