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.
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 executeWATCH
andUNWATCH
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.RedisOp can be passed for execution to RedisOpExecutor (implemented by e.g. RedisNodeClient).