object RedisApi
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:
- RedisApi.Raw - type returned for each command-method is RawCommand. Probably the only reason to use this API variant is to pass a RawCommand to commandGetkeys
- RedisApi.Batches - type returned for each command-method is RedisBatch. Batch can then be combined with other batches to form larger batches, become a part of RedisOp or simply get executed by RedisExecutor (e.g. one of Redis client implementations).
- RedisApi.Keyed.Async, RedisApi.Node.Async and RedisApi.Connection.Async variants are the ones that
actually execute commands by sending them to Redis. Because of that, they take an appropriate RedisExecutor
as constructor argument. Execution of commands is asynchronous and results are returned as
Future
s. - RedisApi.Keyed.Blocking, RedisApi.Node.Blocking and RedisApi.Connection.Blocking are similar
to their
Async
counterparts but execution is blocking and results are returned as unwrapped values.
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 String
s (textual) or only ByteString
s (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))
- Alphabetic
- By Inheritance
- RedisApi
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- class Batches[S <: RedisSerialization] extends AbstractRedisApi[S] with RedisConnectionApi with RedisBatchApi
- class Raw[S <: RedisSerialization] extends AbstractRedisApi[S] with RedisConnectionApi with RedisRawApi
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
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
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()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
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()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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( ... )
-
object
Batches
Entry point for API variants which return RedisBatches.
-
object
Connection extends ExecutedApis
Entry point for API variants which expose all commands, including connection-level ones, i.e.
Entry point for API variants which expose all commands, including connection-level ones, i.e. the ones that access or modify Redis connection state.
-
object
Keyed extends ExecutedApis
Entry point for API variants which expose only keyed commands.
-
object
Node extends ExecutedApis
Entry point for API variants which expose node-level commands, i.e.
Entry point for API variants which expose node-level commands, i.e. the ones that don't access or modify Redis connection state.
-
object
Raw
Entry point for API variants which return RawCommands.