-
Notifications
You must be signed in to change notification settings - Fork 16
Home
Alexandre Curreli edited this page Sep 16, 2013
·
13 revisions
Scredis is an advanced Redis client entirely written in Scala.
- Supports all Redis 2.6.9+ commands
- Native Scala types and customizable parsing
- Asynchronous and synchronous commands processing
- Transactions, pipelining and configurable automatic pipelining
- Customizable timeouts and retries on a per-command basis
- Client pooling
Scredis is compatible with Scala 2.9.x and 2.10.x. Binary releases are hosted on Livestream's Nexus repository.
resolvers += "Livestream Releases" at "https://nexus.lsops.org/nexus/content/repositories/releases/"
libraryDependencies ++= Seq("scredis" %% "scredis" % "0.3.6")
Snapshots will be hosted in a separate repository.
resolvers += "Livestream Snapshots" at "https://nexus.lsops.org/nexus/content/repositories/snapshots/"
libraryDependencies ++= Seq("scredis" %% "scredis" % "1.0.0-SNAPSHOT")
import scredis._
import scala.util.{ Success, Failure }
// Creates a rich asynchronous client with default parameters.
// See reference.conf for the complete list of configurable parameters.
val redis = Redis()
// Import the default execution context for working with futures
import redis.ec
// Futures handling
redis.hGetAll("my-hash") onComplete {
case Success(content) => println(content)
case Failure(e) => e.printStackTrace()
}
// Explicit pipelining
redis.pipelined { p =>
p.hSet("my-hash")("name", "value")
p.hGet("my-hash")("name")
}
// Executes a synchronous command, or any other command synchronously
redis.sync(_.blPop(0, "queue"))
redis.withClient(_.blPop(0, "queue"))
// Disconnects all internal clients and shutdown the default execution context
redis.quit()