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]
- Alphabetic
- By Inheritance
- RedisOp
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
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. -
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def failed: RedisOp[Throwable]
- def fallbackTo[B >: A](op: RedisOp[B]): RedisOp[B]
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def ignoreFailures: RedisOp[Unit]
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](f: (A) ⇒ B): RedisOp[B]
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def recover[B >: A](f: PartialFunction[Throwable, B]): RedisOp[B]
- def recoverWith[B >: A](fun: PartialFunction[Throwable, RedisOp[B]]): RedisOp[B]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
- def transform[B](fun: (commons.Try[A]) ⇒ commons.Try[B]): RedisOp[B]
- def tried: RedisOp[commons.Try[A]]
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )