Packages

package redis

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractRedisApi[S <: RedisSerialization] extends ApiSubset
  2. abstract class AbstractRedisCommand[A] extends RedisCommand[A]
  3. trait ApiSubset extends AnyRef
  4. case class ClusterState(mapping: IndexedSeq[(SlotRange, RedisNodeClient)], masters: commons.BMap[NodeAddress, RedisNodeClient], nonClustered: commons.Opt[RedisNodeClient] = Opt.Empty) extends Product with Serializable

    Current cluster state known by RedisClusterClient.

    Current cluster state known by RedisClusterClient.

    mapping

    mapping between slot ranges and node clients that serve them, sorted by slot ranges

    masters

    direct mapping between master addresses and node clients

    nonClustered

    non-empty if there's actually only one, non-clustered Redis node - see fallbackToSingleNode

  5. final class CollectionBatch[A, C] extends RedisBatch[C] with RawCommandPacks
  6. final class CommandEncoder extends AnyVal
  7. trait ConnectionCommand extends RawCommand
  8. abstract class ExecutedApis extends AnyRef
  9. trait FlatMapper[A, B, -L, -R] extends AnyRef

    Typeclass that steers flat-mapping of RedisBatches and RedisOps with each other.

    Typeclass that steers flat-mapping of RedisBatches and RedisOps with each other. It could be defined simpler as:

    trait FlatMapper[-L[_],-R[_]] {
      def flatMap[A,B](left: L[A])(rightFun: A => R[B]): RedisOp[B]
    }

    but unfortunately IntelliJ Scala plugin (3.0.7.31) does not understand that well (in flatMap callsites)

  10. trait HasFlatMap[L[_]] extends AnyRef
  11. trait ImmediateBatch[+A] extends RedisBatch[A] with RawCommandPacks
  12. trait LowPriorityRedisDataCodecs extends AnyRef
  13. sealed trait LowPriorityRedisRecordCodecs extends AnyRef
  14. final case class NodeAddress(ip: String = NodeAddress.DefaultIP, port: Int = NodeAddress.DefaultPort) extends Product with Serializable
  15. trait NodeCommand extends RawCommand
  16. trait OperationCommand extends RawCommand
  17. trait RawCommand extends RawCommandPack with RawCommands with ReplyPreprocessor
  18. trait RawCommandPack extends RawCommandPacks

    Represents a sequence of commands that is always executed atomically, using a single network call on a single Redis connection.

    Represents a sequence of commands that is always executed atomically, using a single network call on a single Redis connection. RawCommandPack is effectively either a single command or a transaction, optionally preceded by the ASKING special command.

  19. trait RawCommandPacks extends AnyRef

    One or more RawCommandPacks.

    One or more RawCommandPacks. Conceptually pretty much the same as Traversable[RawCommandPack]] but more lightweight.

  20. trait RawCommands extends AnyRef

    One or more raw Redis commands.

    One or more raw Redis commands. More lightweight than regular Scala collection (avoids wrapping in case of single element).

  21. trait RecoverableApiSubset extends ApiSubset
  22. case class Redirection(address: NodeAddress, slot: Int, ask: Boolean) extends Product with Serializable
  23. trait RedisAsyncApi extends RedisExecutedApi
  24. trait RedisBatch[+A] extends AnyRef

    Represents a Redis command or a set of commands sent to Redis as a single batch (usually in a single network message).

    Represents a Redis command or a set of commands sent to Redis as a single batch (usually in a single network message). RedisBatch yields a result of type A which is decoded from responses to commands from this batch. Execution of a batch may also fail for various reasons. Therefore, RedisBatch contains API that allows to recover from failures, e.g. RedisBatch.tried.

    RedisBatches may be combined with each other to form bigger batches. The simpliest primitive for combining batches is RedisBatch.map2 operation while the most convenient way is by using RedisBatch.sequence operation which is powered by Sequencer typeclass.

    RedisBatch can be turned into a RedisOp or executed by RedisExecutor (e.g. one of Redis client implementations).

    A

    result yield by this batch

  25. trait RedisBatchApi extends ApiSubset
  26. abstract class RedisBinaryCommand extends AbstractRedisCommand[ByteString]
  27. trait RedisBlockingApi extends RedisExecutedApi
  28. abstract class RedisBooleanCommand extends AbstractRedisCommand[Boolean]
  29. final class RedisClusterClient extends RedisKeyedExecutor with Closeable

    Redis client implementation for Redis Cluster deployments.

    Redis client implementation for Redis Cluster deployments. Internally, it uses single RedisNodeClient instance for every known master in the cluster plus a separate connection for monitoring of every known master. RedisNodeClient instances are dynamically created and destroyed as the cluster changes its state.

    The cluster client is only able to execute commands or transactions containing keys which determine which master should be contacted. However, it's possible to gain access to RedisNodeClient instances that RedisClusterClient internally uses to connect to every master (see ClusterState and masterClient).

    RedisClusterClient can directly execute only RedisBatches. It automatically distributes every batch over multiple cluster masters and handles cluster redirections if necessary. See executeBatch for more details.

    RedisClusterClient cannot directly execute RedisOps (e.g. WATCH-MULTI-EXEC transactions). You must manually access node client for appropriate master through currentState and execute the operation using it. However, be aware that you must manually handle cluster redirections and cluster state changes while doing so.

  30. trait RedisCommand[+A] extends SinglePackBatch[A] with RawCommand
  31. trait RedisConnectionApi extends RedisOperationApi with ConnectionClusterApi with ConnectionConnectionApi with ConnectionServerApi with ConnectionScriptingApi
  32. final class RedisConnectionClient extends RedisConnectionExecutor with Closeable

    Redis client that uses a single, non-reconnectable connection.

    Redis client that uses a single, non-reconnectable connection. This is the most "raw" client implementation and the only one capable of directly executing connection state changing commands like AUTH, CLIENT SETNAME, WATCH, etc.

    However, note that connection-setup commands like AUTH may also be specified in ConnectionConfig (which may also be specified for connections used by RedisNodeClient and RedisClusterClient).

    This type of client should only be used when requiring capability of manual handling of connection state. If you simply need a single-connection, reconnectable client, use RedisNodeClient with connection pool size configured to 1.

  33. trait RedisConnectionExecutor extends RedisNodeExecutor

    Marker subtype of RedisExecutor which guarantees ability to execute all commands implemented by the driver, including the ones that change or access connection state.

  34. case class RedisDataCodec[T](read: (ByteString) ⇒ T, write: (T) ⇒ ByteString) extends Product with Serializable

    Typeclass which expresses that values of some type are serializable to binary form (ByteString) and deserializable from it in order to use them as keys, hash keys and values in Redis commands.

    Typeclass which expresses that values of some type are serializable to binary form (ByteString) and deserializable from it in order to use them as keys, hash keys and values in Redis commands.

    By default, RedisDataCodec is provided for simple types like String, ByteString, Array[Byte], Boolean, Char, all primitive numeric types and NamedEnums (which have NamedEnumCompanion).

    Also, all types which have an instance of GenCodec automatically have an instance of RedisDataCodec.

  35. abstract class RedisDataCommand[A] extends AbstractRedisCommand[A]
  36. class RedisDataInput extends InputAndSimpleInput
  37. final class RedisDataOutput extends OutputAndSimpleOutput
  38. abstract class RedisDataSeqCommand[A] extends AbstractRedisCommand[Seq[A]]
  39. abstract class RedisDataSetCommand[A] extends AbstractRedisCommand[commons.BSet[A]]
  40. abstract class RedisDoubleCommand extends AbstractRedisCommand[Double]
  41. abstract class RedisEnumCommand[E <: NamedEnum] extends AbstractRedisCommand[E]
  42. trait RedisExecutedApi extends RecoverableApiSubset
  43. trait RedisExecutor extends AnyRef

    Base trait for Redis clients with ability to execute RedisBatches.

  44. class RedisFieldDataInput extends RedisDataInput with FieldInput
  45. abstract class RedisIntCommand extends AbstractRedisCommand[Int]
  46. trait RedisKeyedApi extends KeyedKeysApi with StringsApi with KeyedClusterApi with GeoApi with KeyedScriptingApi with HashesApi with SortedSetsApi with ListsApi with SetsApi with HyperLogLogApi with StreamsApi
  47. trait RedisKeyedExecutor extends RedisExecutor

    Marker subtype of RedisExecutor which guarantees ability to execute Redis commands which contain keys.

  48. abstract class RedisLongCommand extends AbstractRedisCommand[Long]
  49. trait RedisNodeApi extends RedisKeyedApi with NodeKeysApi with NodeServerApi with NodeClusterApi with NodeConnectionApi with NodeScriptingApi
  50. final class RedisNodeClient extends RedisNodeExecutor with Closeable

    Redis client implementation for a single Redis node using a connection pool.

    Redis client implementation for a single Redis node using a connection pool. Connection pool size is constant and batches and operations are distributed over connections using round-robin scheme. Connections are automatically reconnected upon failure (possibly with an appropriate delay, see NodeConfig for details).

  51. trait RedisNodeExecutor extends RedisKeyedExecutor with RedisOpExecutor

    Marker subtype of RedisExecutor which guarantees ability to execute commands which do NOT access or change state of a single Redis connection (e.g.

    Marker subtype of RedisExecutor which guarantees ability to execute commands which do NOT access or change state of a single Redis connection (e.g. CLIENT SETNAME).

  52. abstract class RedisNothingCommand extends AbstractRedisCommand[Nothing]
  53. sealed trait RedisOp[+A] extends AnyRef

    Represents a sequence of Redis operations executed using a single Redis connection.

    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).

  54. trait RedisOpExecutor extends AnyRef

    Base trait for Redis clients with ability to execute RedisOps.

  55. trait RedisOperationApi extends RedisNodeApi with TransactionApi
  56. abstract class RedisOptCommand[T] extends AbstractRedisCommand[commons.Opt[T]]
  57. abstract class RedisOptDataCommand[A] extends AbstractRedisCommand[commons.Opt[A]]
  58. abstract class RedisOptDataSeqCommand[A] extends AbstractRedisCommand[Seq[commons.Opt[A]]]
  59. abstract class RedisOptDoubleCommand extends AbstractRedisCommand[commons.Opt[Double]]
  60. abstract class RedisOptLongCommand extends AbstractRedisCommand[commons.Opt[Long]]
  61. abstract class RedisOptSeqCommand[T] extends AbstractRedisCommand[commons.Opt[Seq[T]]]
  62. abstract class RedisOptStringCommand extends AbstractRedisCommand[commons.Opt[String]]
  63. abstract class RedisPositiveLongCommand extends AbstractRedisCommand[commons.Opt[Long]]
  64. trait RedisRawApi extends ApiSubset
  65. abstract class RedisRawCommand extends AbstractRedisCommand[ValidRedisMsg]
  66. case class RedisRecordCodec[T](read: (IndexedSeq[BulkStringMsg]) ⇒ T, write: (T) ⇒ IndexedSeq[BulkStringMsg]) extends Product with Serializable
    Annotations
    @implicitNotFound( ... )
  67. class RedisRecordInput extends ObjectInput
  68. class RedisRecordOutput extends ObjectOutput
  69. trait RedisRecoverableConnectionApi extends RedisRecoverableNodeApi with RedisConnectionApi
  70. trait RedisRecoverableKeyedApi extends RedisKeyedApi with RecoverableKeyedScriptingApi
  71. trait RedisRecoverableNodeApi extends RedisRecoverableKeyedApi with RedisNodeApi
  72. abstract class RedisScanCommand[T] extends AbstractRedisCommand[(Cursor, Seq[T])]
  73. abstract class RedisSeqCommand[T] extends AbstractRedisCommand[Seq[T]]
  74. trait RedisSerialization extends AnyRef

    Encapsulates types that Redis commands may be parameterized with and provides serialization for these types.

  75. abstract class RedisSimpleStringCommand extends AbstractRedisCommand[String]
  76. abstract class RedisUnitCommand extends AbstractRedisCommand[Unit]
  77. trait ReplyPreprocessor extends AnyRef

    Something that translates incoming RedisMsg messages and emits a single RedisReply.

    Something that translates incoming RedisMsg messages and emits a single RedisReply. For example, it may handle transactions by extracting actual responses for every command from the EXEC response and returning them in a TransactionReply (see Transaction).

  78. trait Sequencer[Ops, Res] extends AnyRef

    Typeclass for easy merging ("sequencing") of multiple RedisBatch instances into one.

    Typeclass for easy merging ("sequencing") of multiple RedisBatch instances into one. This is done in order to guarantee that some set of operations is sent to Redis as a single batch (most likely single network message).

    The parameter Ops represents batches that will be sequenced into one. It may be a collection, a tuple or any other "collection-like" type for which type class instance is provided.

    Res is the type of result of the batch created by "sequencing". This type is automatically inferred from the Ops type. For example, if Ops is (RedisBatch[Int], RedisBatch[String]) (tuple) then Res will be (Int, String). If Ops is List[RedisBatch[Int]] then Res will be List[Int].

    Nesting is also possible. For example, if Ops is (List[RedisBatch[Int]], RedisBatch[String]) then Res will be (List[Int], String).

    In order to perform "sequencing", simply call sequence on your collection of batches, e.g.

    import RedisApi.Batches.StringTyped._
    
    val tupleBatch: RedisBatch[(Long, Opt[String])] = (incr("key1"), get("key2")).sequence
    val listBatch: RedisBatch[List[Long]] = List("key1", "key2").map(key => incr(key)).sequence
    Annotations
    @implicitNotFound( ... )
  79. trait SinglePackBatch[+A] extends RedisBatch[A] with RawCommandPack
  80. final class Transaction[+A] extends SinglePackBatch[A]
  81. trait TupleSequencers extends AnyRef
  82. trait UnsafeCommand extends RawCommand
  83. trait WatchState extends AnyRef

Value Members

  1. object ApiSubset
  2. object ClusterState extends Serializable
  3. object CommandEncoder
  4. object FlatMapper
  5. object Gen
  6. object HasFlatMap
  7. object Hash

    Implementation of key hashing function used in Redis Cluster, as specified in Redis Cluster Specification

  8. object NodeAddress extends Serializable
  9. object RawCommand
  10. object RawCommandPacks
  11. object RedirectionError
  12. object RedirectionException
  13. object RedirectionReply
  14. object RedisApi

    Object which contains implementations of various variants of Redis API that this driver provides.

    Object which contains implementations of various variants of Redis API that this driver provides. Each variant implements a set of methods corresponding directly to Redis commands, e.g. get method represents Redis GET command.

    API variants may differ from each other in several independent aspects:

    The most important one is the result type returned by every method corresponding to a Redis command:

    Async and Blocking API variants additionally come in three different "levels", each one exposing different subset of Redis commands. This reflects the fact that not every RedisExecutor (client implementation) supports every command (e.g. you can't execute unkeyed commands using RedisClusterClient).

    • Variants from RedisApi.Keyed include only commands with keys (so that they can be executed on Redis Cluster)
    • Variants from RedisApi.Node include only commands which don't access connection state
    • Variants from RedisApi.Connection include all commands supported by the driver

    Every API variant may also use different types to represent Redis keys, hash keys and values. You can define your own API variants for arbitrary combination of key, hash key and value types as long as there is an instance of RedisDataCodec for every of these types. Also, it is possible to customize Record type which is used primarily for entries in Redis Stream API. Record type requires RedisRecordCodec instance.

    Key, field, value and record types and their serialization typeclass instances are enapsulated by RedisSerialization instances. API variants are then parameterized with them.

    API variants which use only Strings (textual) or only ByteStrings (binary) are already implemented by the driver, e.g. RedisApi.Keyed.Async.StringTyped, RedisApi.Batches.BinaryTyped.

    Note that RedisDataCodec is automatically provided for many simple types and also all types which have a GenCodec. This effectively gives you a complete serialization framework for keys, hash keys and values stored in Redis.

    Note that chosen key, hash key and value types can be adjusted "on the fly" with a convenient syntax. For example, if you need to use some case class as a value type in a single, specific place, you can do it without defining a completely separate API variant. For example:

    case class Person(name: String, birthYear: Int)
    object Person {
      implicit val codec: GenCodec[Person] = GenCodec.materialize[Person]
    }
    
    import scala.concurrent.duration._
    implicit val system: ActorSystem = ActorSystem()
    
    val api = RedisApi.Keyed.Blocking.StringTyped(new RedisClusterClient)
    
    // normally, we're just using String-typed API
    api.set("key", "value")
    
    // but in one specific place, we might want to use Person as the value
    // Person has an instance of GenCodec, so it will be automatically serialized to binary format
    api.valueType[Person].set("binaryDataKey", Person("Fred", 1990))
  15. object RedisBatch extends HasFlatMap[RedisBatch]
  16. object RedisDataCodec extends LowPriorityRedisDataCodecs with Serializable
  17. object RedisDataInput
  18. object RedisDataOutput
  19. object RedisDataUtils
  20. object RedisOp extends HasFlatMap[RedisOp]
  21. object RedisRecordCodec extends LowPriorityRedisRecordCodecs with Serializable
  22. object RedisSerialization
  23. object Sequencer extends TupleSequencers
  24. object TryagainReply
  25. object TupleSequencers

Ungrouped