Trait/Object

com.avsystem.commons.redis

RedisOp

Related Docs: object RedisOp | package redis

Permalink

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
AnyRef, Any
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. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def asking: RedisOp[A]

    Permalink

    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.

  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def failed: RedisOp[Throwable]

    Permalink
  10. def fallbackTo[B >: A](op: RedisOp[B]): RedisOp[B]

    Permalink
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  14. def ignoreFailures: RedisOp[Unit]

    Permalink
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. def map[B](f: (A) ⇒ B): RedisOp[B]

    Permalink
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. def recover[B >: A](f: PartialFunction[Throwable, B]): RedisOp[B]

    Permalink
  21. def recoverWith[B >: A](fun: PartialFunction[Throwable, RedisOp[B]]): RedisOp[B]

    Permalink
  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  23. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  24. def transform[B](fun: (commons.Try[A]) ⇒ commons.Try[B]): RedisOp[B]

    Permalink
  25. def tried: RedisOp[commons.Try[A]]

    Permalink
  26. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped