Packages

sealed trait RedisOp[+A] extends AnyRef

Represents a sequence of Redis operations executed using a single Redis connection. Any operation may depend on the result of some previous operation (therefore, flatMap is available). RedisOp is guaranteed to be executed fully and exclusively on a single Redis connection (no other concurrent commands can be executed on that connection during execution of RedisOp). Because of that, RedisOps may execute WATCH and UNWATCH commands.

In fact, the primary purpose of RedisOp is to allow execution of Redis transactions with optimistic locking. For this purpose, RedisOp may be created by flat-mapping RedisBatches.

For example, below is an implementation of Redis transaction which fetches a value of some key (as Int) multiplies it by 3 and saves it back to Redis. During this operation, the key being modified is watched so that saving fails with OptimisticLockException if some other client concurrently modifies that key.

val api = RedisApi.Batches.StringTyped.valueType[Int]
import api._
val transactionOp: RedisOp[Unit] = for {
  // we're sending WATCH and GET commands in a single batch
  value <- watch("number") *> get("number").map(_.getOrElse(1))
  // SET command is wrapped in MULTI-EXEC block
  _ <- set("number", value * 3).transaction
} yield ()

RedisOp can be passed for execution to RedisOpExecutor (implemented by e.g. RedisNodeClient).

Self Type
RedisOp[A]
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RedisOp
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. def asking: RedisOp[A]

    Ensures that every keyed command in this operation is prepended with special ASKING command.

    Ensures that every keyed command in this operation is prepended with special ASKING command. This is necessary only when manually handling Redis Cluster redirections.

  2. def failed: RedisOp[Throwable]
  3. def fallbackTo[B >: A](op: RedisOp[B]): RedisOp[B]
  4. def ignoreFailures: RedisOp[Unit]
  5. def map[B](f: (A) ⇒ B): RedisOp[B]
  6. def recover[B >: A](f: PartialFunction[Throwable, B]): RedisOp[B]
  7. def recoverWith[B >: A](fun: PartialFunction[Throwable, RedisOp[B]]): RedisOp[B]
  8. def transform[B](fun: (commons.Try[A]) ⇒ commons.Try[B]): RedisOp[B]
  9. def tried: RedisOp[commons.Try[A]]