Lists API

Purely functional interface for the Lists API.

List Commands usage

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

import cats.effect.IO
import cats.syntax.all._

val testKey = "listos"

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

commandsApi.use { cmd => // ListCommands[IO, String, String]
  for {
    _ <- cmd.rPush(testKey, "one", "two", "three")
    x <- cmd.lRange(testKey, 0, 10)
    _ <- putStrLn(s"Range: $x")
    y <- cmd.lLen(testKey)
    _ <- putStrLn(s"Length: $y")
    a <- cmd.lPop(testKey)
    _ <- putStrLn(s"Left Pop: $a")
    b <- cmd.rPop(testKey)
    _ <- putStrLn(s"Right Pop: $b")
    z <- cmd.lRange(testKey, 0, 10)
    _ <- putStrLn(s"Range: $z")
  } yield ()
}